JS reserved keywords causing crash?

OS (e.g. Win10): Mac 11.2.1
PsychoPy version (e.g. 1.84.x): v2021.1.1
Standard Standalone? (y/n) If not then what?: yes
What are you trying to achieve?: javascript conversion

Experiment Link: Pavlovia (though note that the oinline version won’t work because of the JS problem)

So this is an odd one: Custom Code element works fine, but the inclusion of any “if” statement (e.g., “if (1 === 1) {}”) in the javascript side generates the following error:

“Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 692, in fileSave
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 759, in fileExport
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 73, in generateScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 242, in compileScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 214, in _makeTarget
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 265, in writeScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/routine.py”, line 287, in writeRoutineBeginCodeJS
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/components/code/init.py”, line 231, in writeRoutineStartCodeJS
TypeError: str returned non-string (type NoneType)”

In turn, the javascript file won’t update.

Same behaviour occurs for other reserved keywords (e.g., var, for, etc.). Simply defining variable, however (e.g., test = 0;) is fine.

1 Like

I am having the same problem, also using if statements in code components:

https://discourse.psychopy.org/t/js-compile-typeerror-str-returned-non-string-type-nonetype/20785

have not found solution yet.

Looks like a bug in 2011.1.0 and .1, and Jon is on it (thank you!). Temporary solution here: Errors Pushing to Pavlovia PsychoPy 2021.1.0

1 Like