Fix NameError: piomatter is not defined in pi5_adapter#122
Merged
ty-porter merged 2 commits intoty-porter:mainfrom Mar 4, 2026
Merged
Fix NameError: piomatter is not defined in pi5_adapter#122ty-porter merged 2 commits intoty-porter:mainfrom
ty-porter merged 2 commits intoty-porter:mainfrom
Conversation
added 2 commits
March 3, 2026 16:10
ty-porter
approved these changes
Mar 4, 2026
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.
The Issue:
When running the emulator on a Raspberry Pi 5 using the
pi5_adapter, aNameError: name 'piomatter' is not definedoccurs in load_emulator_window.This happened because
adafruit_blinka_raspberry_pi5_piomatterwas being conditionally imported inside the __ensure_pi5_runtime method. Because the import was scoped to that specific method, thepiomattermodule was not available globally to other methods in the class (such as load_emulator_window), causing it to crash when creating the canvas.The Fix:
adafruit_blinka_raspberry_pi5_piomatterto the module level (top of init.py) using atry...except ImportErrorblock.[pi5]extras were not installed), it safely falls back topiomatter = None.if piomatter is None:to trigger the standardLogger.critical()dependency warning andsys.exit(1).This ensures that the hardware and dependency validations continue to function exactly as intended, while properly scoping the
piomattermodule so thatload_emulator_windowcan access it successfully.