Skip to content

Commit f205f21

Browse files
authored
Merge pull request #77 from trailofbits/76-fix-pydiff-build-tree
Fixes a bug in building Python object diffs
2 parents 96df7f9 + e2b65b2 commit f205f21

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

docs/_templates/layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
{% endfor %}
1818
{% else %}
1919
<dd><a href="/graphtage/latest">latest</a></dd>
20+
<dd><a href="/graphtage/v0.3.0">0.3.0</a></dd>
2021
<dd><a href="/graphtage/v0.2.9">0.2.9</a></dd>
2122
<dd><a href="/graphtage/v0.2.8">0.2.8</a></dd>
2223
<dd><a href="/graphtage/v0.2.7">0.2.7</a></dd>

graphtage/pydiff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ def __init__(self, key, value):
212212
stack.append((obj, [], [obj.value]))
213213
elif isinstance(obj, dict):
214214
stack.append(({}, [], [DictValue(key=k, value=v) for k, v in reversed(list(obj.items()))]))
215-
elif isinstance(python_obj, (list, tuple)):
215+
elif isinstance(obj, (list, tuple)):
216216
stack.append(([], [], list(reversed(obj))))
217-
elif python_obj is None:
217+
elif obj is None:
218218
new_node = NullNode()
219219
else:
220220
pyobj = PyObj(class_name=StringNode(obj.__class__.__name__, quoted=False), attrs=None) # type: ignore

graphtage/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def git_branch() -> Optional[str]:
5959
"""
6060

6161

62-
__version__: Tuple[Union[int, str], ...] = (0, 2, 9)
62+
__version__: Tuple[Union[int, str], ...] = (0, 3, 0)
6363

6464
if DEV_BUILD:
6565
branch_name = git_branch()

test/test_pydiff.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,13 @@ def __init__(self, bar, baz):
2323

2424
printer = graphtage.printer.Printer(ansi_color=True)
2525
print_diff(Foo("bar", "baz"), Foo("bar", "bak"), printer=printer)
26+
27+
def test_nested_tuple_diff(self):
28+
tree = build_tree({"a": (1, 2)})
29+
self.assertIsInstance(tree, graphtage.DictNode)
30+
children = tree.children()
31+
self.assertEqual(1, len(children))
32+
kvp = children[0]
33+
self.assertIsInstance(kvp, graphtage.KeyValuePairNode)
34+
self.assertIsInstance(kvp.key, graphtage.StringNode)
35+
self.assertIsInstance(kvp.value, graphtage.ListNode)

0 commit comments

Comments
 (0)