Merge pull request #3624 from minrk/argunicode

fix some unicode in zmqhandlers

Prevented session identity from being set properly, which in turn prevented stdin from working in the notebook in Python 3.

closes #3494
This commit is contained in:
Min RK 2013-07-14 11:19:57 -07:00
commit f3fa5cd181

View File

@ -25,7 +25,7 @@ from zmq.utils import jsonapi
from IPython.kernel.zmq.session import Session
from IPython.utils.jsonutil import date_default
from IPython.utils.py3compat import PY3
from IPython.utils.py3compat import PY3, cast_unicode
from .handlers import IPythonHandler
@ -83,7 +83,7 @@ class ZMQStreamHandler(websocket.WebSocketHandler):
class AuthenticatedZMQStreamHandler(ZMQStreamHandler, IPythonHandler):
def open(self, kernel_id):
self.kernel_id = kernel_id.decode('ascii')
self.kernel_id = cast_unicode(kernel_id, 'ascii')
self.session = Session(config=self.config)
self.save_on_message = self.on_message
self.on_message = self.on_first_message
@ -97,7 +97,7 @@ class AuthenticatedZMQStreamHandler(ZMQStreamHandler, IPythonHandler):
msg = msg.encode('utf8', 'replace')
try:
identity, msg = msg.split(':', 1)
self.session.session = identity.decode('ascii')
self.session.session = cast_unicode(identity, 'ascii')
except Exception:
logging.error("First ws message didn't have the form 'identity:[cookie]' - %r", msg)