# Buggy code
def open(self, kernel_id):
    self.kernel_id = kernel_id.decode("ascii")
    self.session = Session(parent=self)
    self.save_on_message = self.on_message
    self.on_message = self.on_first_message


# Traceback (TraitError)
ERROR:root:Uncaught exception in /kernels/3c8b14ec-662f-4360-bc2a-4706c67f8513/shell
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 254, in wrapper
return callback(*args, **kwargs)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/html/base/zmqhandlers.py", line 87, in open
self.session = Session(parent=self)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/kernel/zmq/session.py", line 395, in __init__
super(Session, self).__init__(**kwargs)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/config/configurable.py", line 88, in __init__
self.parent = parent
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/traitlets.py", line 315, in __set__
new_value = self._validate(obj, value)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/traitlets.py", line 323, in _validate
return self.validate(obj, value)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/traitlets.py", line 809, in validate
self.error(obj, value)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/traitlets.py", line 646, in error
raise TraitError(e)
TraitError: The 'parent' trait of a Session instance must be a Configurable or None, but a value of class 'IPython.html.services.kernels.handlers.ShellHandler' (i.e. <IPython.html.services.kernels.handlers.ShellHandler object at 0x1088c0950>) was specified.
ERROR:root:Uncaught exception, closing connection.
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 304, in wrapper
callback(*args)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/httpserver.py", line 250, in _on_headers
self.request_callback(self._request)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/web.py", line 1362, in __call__
handler._execute(transforms, *args, **kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 120, in _execute
self.ws_connection.accept_connection()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 454, in accept_connection
self._accept_connection()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 496, in _accept_connection
self._receive_frame()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 525, in _receive_frame
self.stream.read_bytes(2, self._on_frame_start)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 180, in read_bytes
self._check_closed()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 535, in _check_closed
raise IOError("Stream is closed")
IOError: Stream is closed
ERROR:root:Exception in callback <zmq.eventloop.stack_context._StackContextWrapper object at 0x108671890>
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/zmq/eventloop/ioloop.py", line 418, in _run_callback
callback()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 304, in wrapper
callback(*args)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/httpserver.py", line 250, in _on_headers
self.request_callback(self._request)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/web.py", line 1362, in __call__
handler._execute(transforms, *args, **kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 120, in _execute
self.ws_connection.accept_connection()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 454, in accept_connection
self._accept_connection()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 496, in _accept_connection
self._receive_frame()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 525, in _receive_frame
self.stream.read_bytes(2, self._on_frame_start)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 180, in read_bytes
self._check_closed()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 535, in _check_closed
raise IOError("Stream is closed")
IOError: Stream is closed
ERROR:root:Uncaught exception in /kernels/3c8b14ec-662f-4360-bc2a-4706c67f8513/stdin
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 254, in wrapper
return callback(*args, **kwargs)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/html/base/zmqhandlers.py", line 87, in open
self.session = Session(parent=self)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/kernel/zmq/session.py", line 395, in __init__
super(Session, self).__init__(**kwargs)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/config/configurable.py", line 88, in __init__
self.parent = parent
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/traitlets.py", line 315, in __set__
new_value = self._validate(obj, value)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/traitlets.py", line 323, in _validate
return self.validate(obj, value)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/traitlets.py", line 809, in validate
self.error(obj, value)
File "/Users/bgranger/Documents/Computing/IPython/code/ipython/IPython/utils/traitlets.py", line 646, in error
raise TraitError(e)
TraitError: The 'parent' trait of a Session instance must be a Configurable or None, but a value of class 'IPython.html.services.kernels.handlers.StdinHandler' (i.e. <IPython.html.services.kernels.handlers.StdinHandler object at 0x1085d7510>) was specified.
ERROR:root:Uncaught exception, closing connection.
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 304, in wrapper
callback(*args)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/httpserver.py", line 250, in _on_headers
self.request_callback(self._request)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/web.py", line 1362, in __call__
handler._execute(transforms, *args, **kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 120, in _execute
self.ws_connection.accept_connection()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 454, in accept_connection
self._accept_connection()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 496, in _accept_connection
self._receive_frame()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 525, in _receive_frame
self.stream.read_bytes(2, self._on_frame_start)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 180, in read_bytes
self._check_closed()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 535, in _check_closed
raise IOError("Stream is closed")
IOError: Stream is closed
ERROR:root:Exception in callback <zmq.eventloop.stack_context._StackContextWrapper object at 0x108671890>
Traceback (most recent call last):
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/zmq/eventloop/ioloop.py", line 418, in _run_callback
callback()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 304, in wrapper
callback(*args)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/httpserver.py", line 250, in _on_headers
self.request_callback(self._request)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/web.py", line 1362, in __call__
handler._execute(transforms, *args, **kwargs)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 120, in _execute
self.ws_connection.accept_connection()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 454, in accept_connection
self._accept_connection()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 496, in _accept_connection
self._receive_frame()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/websocket.py", line 525, in _receive_frame
self.stream.read_bytes(2, self._on_frame_start)
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 180, in read_bytes
self._check_closed()
File "/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/tornado/iostream.py", line 535, in _check_closed
raise IOError("Stream is closed")
IOError: Stream is closed

# Fixed code
def open(self, kernel_id):
    self.kernel_id = kernel_id.decode("ascii")
    self.session = Session(config=self.config)
    self.save_on_message = self.on_message
    self.on_message = self.on_first_message