Fix AttributeError: KeyboardDevice missing _buffers attribute wo PTB#7494
Merged
peircej merged 1 commit intopsychopy:devfrom Jan 21, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #7494 +/- ##
==========================================
- Coverage 48.93% 48.31% -0.63%
==========================================
Files 355 355
Lines 64990 65250 +260
==========================================
- Hits 31806 31524 -282
- Misses 33184 33726 +542
🚀 New features to boost your workflow:
|
Contributor
|
Thanks for catching this! The test fails are due to GitHub deprecating the version of Mac OS we were using for the runners - I've just pulled in a fix to the release branch and am currently merging those changes into the dev branch, so once this PR is in: you should be able to merge from the dev branch and have tests pass. Once they do I'm happy to pull this in :) |
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.
Problem
When trying to play a movie clip (mp4 container) from a local drive, KeyboardDevice crashes with
AttributeError: 'KeyboardDevice' object has no attribute '_buffers'when using non-PTB backends (iohub or event). I think this is because these attributes are only initialized in the PTB backend branch (but I'm not using that)Solution
Just initialize
_buffersand_devsas empty dicts at the end of__init__. This ensures the attributes exist even when the PTB backend is not used. I think all actual usages of these attributes have other checks, so empty dicts should be harmless. I think....Testing
Tested with movie playback using iohub backend - previously crashed, now works correctly! Also the movie plays very smoothly.