| Reference | Downloads | Github

Making the fromFile function compatible with psydat files obtained with Python 2 (easy fix)

I was trying to load some old .psydat files obtained under python 2 and got the following error:

    contents = pickle.load(f)
UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 2: ordinal not in range(128)

A simple fix consists in adding the argument encoding=‘latin1’ line 55 of the

        with open(filename, 'rb') as f:
            contents = pickle.load(f, encoding='latin1')

Might be good to correct this in future versions (sorry if it has been corrected in new versions).
All the best,

Yes. Maybe do this with a try…except on the UnicodeDecodeError so that existing loads also work (I don’t think Latin1 will work universally, only for old files).

Do you want to submit a Pull Request?


1 Like