Merge pull request #1353 from takluyver/i1345

Save notebook as script using unicode file handle.

Using io.open(), which is the Python 3 open() in 2.6 and above.

Closes #1345
This commit is contained in:
Min RK 2012-02-08 15:14:47 -08:00
commit 6b2cb224cd

View File

@ -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', encoding='utf-8') 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)