open-cogsci/pyqode.core

Trying to save a file that was opened with an invalid encoding results in `UnicodeDecodeError`

Opened this issue · 0 comments

If you open a binary file, this first leads to the encoding panel being shown. If you then try to save the file again, the following error pops up:

Traceback (most recent call last):
  File "/usr/share/opensesame_extensions/OpenSesameIDE/OpenSesameIDE.py", line 413, in save_file
    self._scetw.save_current()
  File "/home/sebastiaan/.local/lib/python3.9/site-packages/pyqode/core/widgets/splittable_tab_widget.py", line 1572, in save_current
    self._save(editor)
  File "/home/sebastiaan/.local/lib/python3.9/site-packages/pyqode/core/widgets/splittable_tab_widget.py", line 1584, in _save
    old_content = f.read()
  File "/usr/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 37: invalid continuation byte