mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Fix writing JSON on Python 2
This commit is contained in:
parent
425d5a1c02
commit
c26b0f6961
@ -7,6 +7,7 @@ import os
|
||||
import io
|
||||
from tornado import web
|
||||
|
||||
from IPython.utils.py3compat import PY3
|
||||
from ...base.handlers import IPythonHandler, json_errors
|
||||
|
||||
def recursive_update(target, new):
|
||||
@ -68,8 +69,13 @@ class ConfigHandler(IPythonHandler):
|
||||
update = self.get_json_body()
|
||||
recursive_update(section, update)
|
||||
|
||||
with io.open(filename, 'w', encoding='utf-8') as f:
|
||||
if PY3:
|
||||
f = io.open(filename, 'w', encoding='utf-8')
|
||||
else:
|
||||
f = open(filename, 'wb')
|
||||
with f:
|
||||
json.dump(section, f)
|
||||
|
||||
self.set_status(204)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user