Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More Python 3 compatibility fixes.

  • Loading branch information...
commit 18b24975994c9913e94986749a74673d2ed1d3a3 1 parent e36691a
@takluyver authored
View
8 IPython/parallel/controller/dependency.py
@@ -16,6 +16,7 @@
from IPython.parallel.client.asyncresult import AsyncResult
from IPython.parallel.error import UnmetDependency
from IPython.parallel.util import interactive
+from IPython.utils import py3compat
class depend(object):
"""Dependency decorator, for use with tasks.
@@ -65,9 +66,10 @@ def __call__(self, *args, **kwargs):
raise UnmetDependency()
return self.f(*args, **kwargs)
- @property
- def __name__(self):
- return self.func_name
+ if not py3compat.PY3:
+ @property
+ def __name__(self):
+ return self.func_name
@interactive
def _require(*names):
View
10 IPython/zmq/kernelmanager.py
@@ -188,7 +188,7 @@ def __init__(self, context, session, address):
def run(self):
"""The thread's main activity. Call start() instead."""
self.socket = self.context.socket(zmq.DEALER)
- self.socket.setsockopt(zmq.IDENTITY, self.session.session)
+ self.socket.setsockopt(zmq.IDENTITY, self.session.session.encode("ascii"))
self.socket.connect('tcp://%s:%i' % self.address)
self.iostate = POLLERR|POLLIN
self.ioloop.add_handler(self.socket, self._handle_events,
@@ -394,8 +394,8 @@ def __init__(self, context, session, address):
def run(self):
"""The thread's main activity. Call start() instead."""
self.socket = self.context.socket(zmq.SUB)
- self.socket.setsockopt(zmq.SUBSCRIBE,'')
- self.socket.setsockopt(zmq.IDENTITY, self.session.session)
+ self.socket.setsockopt(zmq.SUBSCRIBE,b'')
+ self.socket.setsockopt(zmq.IDENTITY, self.session.session.encode("ascii"))
self.socket.connect('tcp://%s:%i' % self.address)
self.iostate = POLLIN|POLLERR
self.ioloop.add_handler(self.socket, self._handle_events,
@@ -483,7 +483,7 @@ def __init__(self, context, session, address):
def run(self):
"""The thread's main activity. Call start() instead."""
self.socket = self.context.socket(zmq.DEALER)
- self.socket.setsockopt(zmq.IDENTITY, self.session.session)
+ self.socket.setsockopt(zmq.IDENTITY, self.session.session.encode("ascii"))
self.socket.connect('tcp://%s:%i' % self.address)
self.iostate = POLLERR|POLLIN
self.ioloop.add_handler(self.socket, self._handle_events,
@@ -562,7 +562,7 @@ def __init__(self, context, session, address):
def _create_socket(self):
self.socket = self.context.socket(zmq.REQ)
- self.socket.setsockopt(zmq.IDENTITY, self.session.session)
+ self.socket.setsockopt(zmq.IDENTITY, self.session.session.encode("ascii"))
self.socket.connect('tcp://%s:%i' % self.address)
self.poller = zmq.Poller()
self.poller.register(self.socket, zmq.POLLIN)
View
6 IPython/zmq/session.py
@@ -48,7 +48,7 @@
from IPython.utils.jsonutil import extract_dates, squash_dates, date_default
from IPython.utils.py3compat import str_to_bytes
from IPython.utils.traitlets import (CBytes, Unicode, Bool, Any, Instance, Set,
- DottedObjectName)
+ DottedObjectName, CUnicode)
#-----------------------------------------------------------------------------
# utility functions
@@ -239,10 +239,10 @@ def _unpacker_changed(self, name, old, new):
else:
self.unpack = import_item(str(new))
- session = CBytes(b'', config=True,
+ session = CUnicode(u'', config=True,
help="""The UUID identifying this session.""")
def _session_default(self):
- return bytes(uuid.uuid4())
+ return unicode(uuid.uuid4())
username = Unicode(os.environ.get('USER',u'username'), config=True,
help="""Username for the Session. Default is your system username.""")
Please sign in to comment.
Something went wrong with that request. Please try again.