open-cogsci / OpenSesame

Graphical experiment builder for the social sciences
http://osdoc.cogsci.nl/
GNU General Public License v3.0
236 stars 112 forks source link

copy_sketchpad gives exception: AttributeError: 'Window' object has no attribute '_closed' #815

Open dev-jam opened 1 week ago

dev-jam commented 1 week ago

When using:

my_canvas = copy_sketchpad('stimulus')

with the psychopy backend, I get the following exception:

AttributeError: 'Window' object has no attribute '_closed' Exception ignored in: <function Window.del at 0x7039b75e82c0> Traceback (most recent call last): File "/usr/lib/python3/dist-packages/psychopy/visual/window.py", line 632, in del if self._closed is False: ^^^^^^^^^^^^

Everything seems to work fine except for flooding the cmd window with this exception. I checked the psychopy source and it does not have an attribute _closed but instead it defines the variable self._closed = false in its init, so that might be the problem. I recursively checked the opensesame source but I couldn't find the calling of the _closed attribute.

If I exchange

my_canvas = copy_sketchpad('stimulus')

with:

my_canvas = Canvas()

in my code, I don't get the exception.

I am using opensesame 4.0.29 on debian bookworm with psychopy 2023.1.3.

smathot commented 1 week ago

@dev-jam , thanks for this. This is an error that comes from psychopy, not OpenSesame. It's likely version dependent, and I don't think it affects standard installations of OpenSesame. Therefore, I won't fix it at this time. However, if you find that it does affect standard installations, let me know and then I'll put it back on the agenda.

Otherwise, you can also see if the error persists if you use the latest version of PsychoPy, and then attempt to fix it yourself, of course. The first port of call would be, as you've essentially already done, see where the _closed property is initialized, and why it is not initialized properly in this context.

dev-jam commented 1 week ago

I forgot to test it in the Windows version, so I just tried. Same exception but the windows installer also has 2023.1.3. Gonna try to test it in a higher version but that takes a bit of time because pip will not upgrade easily due to the strict dependencies of psychopy.

I took a look in the psychopy and opensesame source and the only hit i got on ._closed regarding an attribute was:

editor._closed in pyqode_manager.py

Over here:

https://github.com/open-cogsci/OpenSesame/blob/b19f07c74bcc932bac8d943cdff260987361a499/opensesame_extensions/core/pyqode_manager/pyqode_manager.py#L234

As starting point, PyqodeManager inherits all the methods and attributes from the Window class.

Could this be the culprit?