AttributeError ('NoneType' object has no attribute 'read') after update to 2021.1.0

An experiment that used to run without error in a 2020 version* now crashes, after updating to v2021.1.0. Data collection has not been started yet, as the experiment is still under work.
*: Sadly I no longer know the exact previous version.

This happens at the end of a routine that displays some text and some progress dots appearing progressively on the screen (updated at every frame, as per a variable built inside of a code component).

The traceback states:

  File "d:\Experiments\hSs_behav_lastrun.py", line 738, in <module>
    with contextlib.closing(wave.open(file,'r')) as f:
  File "C:\Program Files\PsychoPy3\lib\wave.py", line 499, in open
    return Wave_read(f)
  File "C:\Program Files\PsychoPy3\lib\wave.py", line 163, in __init__
    self.initfp(f)
  File "C:\Program Files\PsychoPy3\lib\wave.py", line 128, in initfp
    self._file = Chunk(file, bigendian = 0)
  File "C:\Program Files\PsychoPy3\lib\chunk.py", line 61, in __init__
    self.chunkname = file.read(4)
AttributeError: 'NoneType' object has no attribute 'read'

At line 738, the following chunk of code starts (all within the thisPractice loop):

with contextlib.closing(wave.open(file,'r')) as f:
    frames = f.getnframes()
    rate = f.getframerate()
    WAVduration = frames / float(rate)
# keep track of which components have finished
choiceComponents = [cross, notes, phrase, rating_text, choiceRating, punctele_2, brackets_2]
for thisComponent in choiceComponents:
    thisComponent.tStart = None
    thisComponent.tStop = None
    thisComponent.tStartRefresh = None
    thisComponent.tStopRefresh = None
    if hasattr(thisComponent, 'status'):
        thisComponent.status = NOT_STARTED
# reset timers
t = 0
_timeToFirstFrame = win.getFutureFlipTime(clock="now")
choiceClock.reset(-_timeToFirstFrame)  # t0 is time of first possible flip
frameN = -1

I know (as per previous threads 1 and 2) that AttributeError means the output is not the expected object, but I could not figure out where in that code chain/traceback this happens.

I can upload the entire experiment if needed for debugging. Thanks in advance!

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2021.1.0
Standard Standalone? (y/n) y

If you could upload the full experiment that would be great, I’m not 100% sure where this is happening so it would be useful to run it myself so I can click through the error stack

Thank you very much Todd, please find the files for the full expt here.

Forgot to mention that it’s the ‘feedback’ routine where the error happens.

I think the problem is when reading in your conditions file - it seems to think that there’s 16 rows when there’s only 1, but the last 15 are all blank (hence the AttributeError - it’s expecting a filename and trying to access the attributes of a string, but it’s getting None).

As a quick fix, go to your loop and delete the contents of the Conditions field. Then click the Open In Excel button to make a new Excel file and paste the contents (as “Text Only”) of the old practice.xlsx file into it, then save over practice.xlsx. As a more long term solution, I’ll look into why the read function is no longer filtering out blank rows.

Good catch, that was it indeed! Funnily enough, the practice.xlsx file I sent was in fact a debug version of the full file, with 1 practice trial instead of 16, which I had created while trying to solve a different problem (to which sadly I got no reaction). It seems a change in the number of rows of the conditions file makes psychoPy stil expect the same number of rows, with this error coming up if that number has changed.

Incidentally, I would point out it’s quite confusing that psychoPy reports the number of rows in a conditions file as “conditions”, since as I understand it, what you normally have across rows are raw trials, a number of which are typically repeated within each (actual) condition.