I get a syntax error in PsychoPy’s PTB logging code. My code:
from psychopy import logging
log = logging.LogFile("WS_Dev.log", level = logging.DEBUG, filemode = "w")
logging.log(logging.DEBUG, "in getArguments()")
and the error message:
File "./myProject.py", line 119, in getArguments
logging.log(logging.DEBUG, "in getArguments()")
File "./myProject-env/lib/python3.8/site-packages/psychopy/logging.py", line 410, in log
root.log(msg, level=level, t=t, obj=obj)
File "./myProject-env/lib/python3.8/site-packages/psychopy/logging.py", line 282, in log
if level < self.lowestTarget:
TypeError: '<' not supported between instances of 'str' and 'int'
While I could get into PsychoPy's source code and fix this myself, I don't want to modify public domain open-source software.
(1) Has anybody else seen this, or got a workaround? I can't believe PsychoPy shipped with such a glaring bug. Yet I see no mention of it in either the PsychoPy forum or stack overflow.
(2) How can I file a bug report against PsychoPy, other than posting this question in the PsychoPy forum?
macOS 12.2.1 (Monterey), 2017 MacBook Pro, PsychoPy 2021.2.3, psychtoolbox 3.0.18.2, Python 3.8
CodePudding user response:
If you look at the documentation for logging.log
...
>>> from psychopy import logging
>>> help(logging.log)
Help on function log in module psychopy.logging:
log(msg, level, t=None, obj=None)
Log a message
usage::
log(level, msg, t=t, obj=obj)
Log the msg, at a given level on the root logger
...it looks like the usage::
documentation has the first two
parameters backwards. According to the function signature, you should
be calling:
logging.log("in getArguments()", logging.DEBUG)
And that seems to work without errors when I test it.
This seems like a good opportunity for making a documentation pull request against the project.