mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-30 12:11:32 +08:00
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:
commit
6b2cb224cd
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user