Skip to content

Commit 5c6b097

Browse files
authored
Merge pull request psychopy#7494 from wadelab/fix-keyboard-buffers-attribute-error
Fix AttributeError: KeyboardDevice missing _buffers attribute wo PTB
2 parents d05e0e6 + a8162bc commit 5c6b097

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

psychopy/hardware/keyboard.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ def __init__(self, device=-1, bufferSize=10000, waitForStart=False, clock=None,
386386

387387
logging.info('keyboard.Keyboard is using %s backend.' % KeyboardDevice._backend)
388388

389+
# Initialize _buffers and _devs for all backends to prevent AttributeError
390+
if not hasattr(self, '_buffers'):
391+
self._buffers = {}
392+
if not hasattr(self, '_devs'):
393+
self._devs = {}
394+
389395
# array in which to store ongoing presses
390396
self._keysStillDown = deque()
391397
# set whether or not to mute any keypresses which happen outside of PsychoPy

0 commit comments

Comments
 (0)