Fix quoted Python attribute receivers - #159
Conversation
Co-authored-by: insisong <emmanuelisaacnsisong@gmail.com>
ESultanik
left a comment
There was a problem hiding this comment.
Thanks for this — the change is correct, and it is the right fix.
isinstance(object, StringNode) was asking whether the builtin type object is a StringNode, so the branch was unreachable and the receiver kept its quotes. Checking self.object makes it do what it was written to do. I confirmed the behavior against master: rendering PyObjAttribute(StringNode("package"), StringNode("member")) produces "package".member before your change and package.member after it, so the new test genuinely fails without the one-line fix rather than passing for an unrelated reason.
Asserting on the rendered output rather than on the quoted flag is the right level for this — it pins the behavior a reader actually cares about, and it would still catch a regression if the quoting decision moved elsewhere in the printing path. Using Printer(ansi_color=False) with a StringIO matches how the rest of the suite captures output.
One note for anyone reading this later: PyObjAttribute is a DataClassNode, and DataClassEdit has no print() override (#150), so edited attribute nodes still render without their syntax. That is a separate bug and out of scope here; this PR is correct on its own.
We cannot merge yet. The CLA check on this PR is still showing as not signed:
https://cla-assistant.io/trailofbits/graphtage?pullRequest=159
Once you sign it, the check will go green and we can land this. If you have already signed and the status has not updated, the recheck link in the CLA bot's comment usually clears it.
|
okay, it was my connection. |

Closes #155.
PyObjAttributechecked the builtinobject, leaving its receiver normalization branch unreachable. Checkself.objectso string receivers render as attribute names instead of quoted string literals.Adds a focused output regression for the receiver and member rendering path.
Validation:
pytest -q(141 passed)ruff check graphtage test docs bindistmake -C docs html(succeeds with two pre-existing duplicate-description warnings)uv buildCo-authored-by: insisong emmanuelisaacnsisong@gmail.com