##// END OF EJS Templates
Specify encoding for loading and saving notebooks.
Thomas Kluyver -
Show More
@@ -213,7 +213,7 b' class FileNotebookManager(NotebookManager):'
213 model['last_modified'] = last_modified
213 model['last_modified'] = last_modified
214 model['created'] = last_modified
214 model['created'] = last_modified
215 if content is True:
215 if content is True:
216 with open(os_path, 'r') as f:
216 with io.open(os_path, 'r', encoding='utf-8') as f:
217 try:
217 try:
218 nb = current.read(f, u'json')
218 nb = current.read(f, u'json')
219 except Exception as e:
219 except Exception as e:
@@ -241,7 +241,7 b' class FileNotebookManager(NotebookManager):'
241 nb['metadata']['name'] = u''
241 nb['metadata']['name'] = u''
242 try:
242 try:
243 self.log.debug("Autosaving notebook %s", os_path)
243 self.log.debug("Autosaving notebook %s", os_path)
244 with open(os_path, 'w') as f:
244 with io.open(os_path, 'w', encoding='utf-8') as f:
245 current.write(nb, f, u'json')
245 current.write(nb, f, u'json')
246 except Exception as e:
246 except Exception as e:
247 raise web.HTTPError(400, u'Unexpected error while autosaving notebook: %s %s' % (os_path, e))
247 raise web.HTTPError(400, u'Unexpected error while autosaving notebook: %s %s' % (os_path, e))
@@ -394,7 +394,7 b' class FileNotebookManager(NotebookManager):'
394 u'Notebook checkpoint does not exist: %s-%s' % (name, checkpoint_id)
394 u'Notebook checkpoint does not exist: %s-%s' % (name, checkpoint_id)
395 )
395 )
396 # ensure notebook is readable (never restore from an unreadable notebook)
396 # ensure notebook is readable (never restore from an unreadable notebook)
397 with open(cp_path, 'r') as f:
397 with io.open(cp_path, 'r', encoding='utf-8') as f:
398 nb = current.read(f, u'json')
398 nb = current.read(f, u'json')
399 shutil.copy2(cp_path, nb_path)
399 shutil.copy2(cp_path, nb_path)
400 self.log.debug("copying %s -> %s", cp_path, nb_path)
400 self.log.debug("copying %s -> %s", cp_path, nb_path)
General Comments 0
You need to be logged in to leave comments. Login now