From d0a04240b67c840cd5395132f59de10443395368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Thu, 8 Feb 2018 14:13:14 +0100 Subject: [PATCH] Fix non-unicode files kill whole webide backend --- src/event_handlers/source_code_event_handler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/event_handlers/source_code_event_handler.py b/src/event_handlers/source_code_event_handler.py index 17ca059..24ed9a4 100644 --- a/src/event_handlers/source_code_event_handler.py +++ b/src/event_handlers/source_code_event_handler.py @@ -30,12 +30,12 @@ class FileManager: @property def file_contents(self): - with open(self._filepath(self.filename), 'r') as ifile: + with open(self._filepath(self.filename), 'r', errors='surrogateescape') as ifile: return ifile.read() @file_contents.setter def file_contents(self, value): - with open(self._filepath(self.filename), 'w') as ofile: + with open(self._filepath(self.filename), 'w', errors='surrogateescape') as ofile: ofile.write(value) def _filepath(self, filename):