From ddeaebcc4c7ea984b5eac8ce768f1c4bf7984812 2012-01-30 21:43:48 From: Thomas Kluyver Date: 2012-01-30 21:43:48 Subject: [PATCH] Save notebook as script using unicode file handle. Closes gh-1345 --- diff --git a/IPython/frontend/html/notebook/notebookmanager.py b/IPython/frontend/html/notebook/notebookmanager.py index 18daf9a..15d8bb4 100644 --- a/IPython/frontend/html/notebook/notebookmanager.py +++ b/IPython/frontend/html/notebook/notebookmanager.py @@ -17,6 +17,7 @@ Authors: #----------------------------------------------------------------------------- import datetime +import io import os import uuid import glob @@ -212,7 +213,7 @@ class NotebookManager(LoggingConfigurable): if self.save_script: pypath = os.path.splitext(path)[0] + '.py' try: - with open(pypath,'w') as f: + with io.open(pypath,'w') as f: current.write(nb, f, u'py') except Exception as e: raise web.HTTPError(400, u'Unexpected error while saving notebook as script: %s' % e)