Skip to content

Commit

Permalink
magickernel: don't crash on attempt to print from %kernel code... doe…
Browse files Browse the repository at this point in the history
…sn't actually show; not sure why not
  • Loading branch information
Doug Blank committed Sep 10, 2014
1 parent b951a44 commit 9a21220
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions jupyter_kernel/magickernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def __init__(self, *args, **kwargs):
# FIXME: take care of input/output, eg StringIO
# make work without a session
self.log = logging.Logger(".magickernel")
else:
# Write has already been set
try:
sys.stdout.write = self.Write
except:
pass # Can't change stdout
self.sticky_magics = {}
self._i = None
self._ii = None
Expand All @@ -41,10 +47,6 @@ def __init__(self, *args, **kwargs):
self.plot_settings = dict(backend='inline', format=None, size=None)
self.hist_file = get_history_file(self)
self.reload_magics()
try:
sys.stdout.write = self.Write
except:
pass # Can't change stdout
# provide a way to get the current instance
import jupyter_kernel
jupyter_kernel.JUPYTER_INSTANCE = self
Expand All @@ -56,6 +58,7 @@ def subkernel(cls, kernel):
FIXME: monkeypatch to Make this kernel class be a subkernel to another.
"""
cls.log = kernel.log
cls.session = kernel.session
cls.iopub_socket = kernel.iopub_socket
cls._parent_header = kernel._parent_header

Expand Down

0 comments on commit 9a21220

Please sign in to comment.