Conversation
…itializeComm() LcdCommRevC.__init__ never initialized self.sub_revision or self.rom_version; they were only set inside _hello() (called from InitializeComm()). Any caller touching these attributes before that point, including the test suite's mocked LcdComm which never calls InitializeComm(), hit AttributeError/UnboundLocalError. sub_revision detection is purely a function of display_width/height (the code's own comment notes the device response is unreliable for this), so move it to __init__ like lcd_comm_rev_a.py already does. rom_version genuinely requires the device handshake, so give it the same default (87) _hello() already falls back to on detection failure. This also exposed that the rev_c golden test fixtures predate the multi-sub-revision support (2.1"/5"/8") added later, so they expected the old single-size DISPLAY_BITMAP payload. Regenerated them with RECORD_GOLDEN=1 to match current, correct behavior. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
LcdCommRevC.__init__never initializedself.sub_revisionorself.rom_version; both were only set inside_hello()(called fromInitializeComm()). Any code path touching these attributes beforeInitializeComm()runs — including the test suite's mockedLcdComm, which never calls it — hitsAttributeError/UnboundLocalError.sub_revisiondetection is purely a function ofdisplay_width/display_height(the existing comment notes the device's own response is unreliable for this), so it's moved to__init__, matching the pattern already used inlcd_comm_rev_a.py.rom_versiongenuinely requires the device handshake, so it gets the same default (87) that_hello()already falls back to when detection fails.rev_cgolden test fixtures predated multi-sub-revision support (2.1"/5"/8") added later, so they expected the old single-sizeDISPLAY_BITMAPpayload. Regenerated with the existingRECORD_GOLDEN=1mechanism to match current, correct behavior.Test plan
python -m pytest tests/— 37/37 passing (was 29 passing / 8 failing onmain)python -m py_compile library/lcd/lcd_comm_rev_c.py🤖 Generated with Claude Code
https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X