Skip to content

Commit

Permalink
Specify encoding when writing user code to a file.
Browse files Browse the repository at this point in the history
  • Loading branch information
novoselt committed May 30, 2016
1 parent 37d22ea commit 35d5339
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion forking_kernel_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ def fork_kernel(self, config, pipe, resource_limits):
import sys
sys.argv = ['sagemathcell.py']
old_execute = ka.kernel.do_execute
import codecs

def new_execute(code, *args, **kwds):
with open("sagemathcell.py", "w") as f:
with codecs.open('sagemathcell.py', 'w', encoding='utf-8') as f:
f.write(code)
return old_execute(code, *args, **kwds)

ka.kernel.do_execute = new_execute
ka.start()

Expand Down

0 comments on commit 35d5339

Please sign in to comment.