##// END OF EJS Templates
Fix writing JSON on Python 2
Thomas Kluyver -
Show More
@@ -7,6 +7,7 b' import os'
7 import io
7 import io
8 from tornado import web
8 from tornado import web
9
9
10 from IPython.utils.py3compat import PY3
10 from ...base.handlers import IPythonHandler, json_errors
11 from ...base.handlers import IPythonHandler, json_errors
11
12
12 def recursive_update(target, new):
13 def recursive_update(target, new):
@@ -68,8 +69,13 b' class ConfigHandler(IPythonHandler):'
68 update = self.get_json_body()
69 update = self.get_json_body()
69 recursive_update(section, update)
70 recursive_update(section, update)
70
71
71 with io.open(filename, 'w', encoding='utf-8') as f:
72 if PY3:
73 f = io.open(filename, 'w', encoding='utf-8')
74 else:
75 f = open(filename, 'wb')
76 with f:
72 json.dump(section, f)
77 json.dump(section, f)
78
73 self.set_status(204)
79 self.set_status(204)
74
80
75
81
General Comments 0
You need to be logged in to leave comments. Login now