Skip to content

Conversation

@TEParsons
Copy link
Contributor

It's because of local vs global namespaces - the variables from the spreadsheet are defined globally, but because the allowedKeys code in a Keyboard Component can set the variable (when it converts it to a tuple or does eval or etc.) and because the run code is now in a function, Python reserves the local name and so if you reference it you get "Variable not defined" (even though it's in globals).

This fixes it by saying that, if the same conditions under which the allowedKeys code is written is True, add some code to the start of the Routine to use the global variable's value for the undefined local variable.

@TEParsons
Copy link
Contributor Author

Spotted by this forum user

@peircej peircej merged commit d5f6345 into psychopy:release May 14, 2024
@TEParsons TEParsons deleted the release-bf-kb-allowedkeys branch May 30, 2024 14:37
@peircej peircej added the 🐞 bug Issue describes a bug (crash or error) or undefined behavior. label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Issue describes a bug (crash or error) or undefined behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants