Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions ipykernel/iostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,27 @@ def __getattr__(self, attr):
# don't wrap magic methods
super(BackgroundSocket, self).__getattr__(attr)
if hasattr(self.io_thread.socket, attr):
warnings.warn("Accessing zmq Socket attribute %s on BackgroundSocket" % attr,
DeprecationWarning, stacklevel=2)
warnings.warn(
"Accessing zmq Socket attribute {attr} on BackgroundSocket"
" is deprecated since ipykernel 4.3.0"
" use .io_thread.socket.{attr}".format(attr=attr),
DeprecationWarning,
stacklevel=2,
)
return getattr(self.io_thread.socket, attr)
super(BackgroundSocket, self).__getattr__(attr)

def __setattr__(self, attr, value):
if attr == 'io_thread' or (attr.startswith('__' and attr.endswith('__'))):
super(BackgroundSocket, self).__setattr__(attr, value)
else:
warnings.warn("Setting zmq Socket attribute %s on BackgroundSocket" % attr,
DeprecationWarning, stacklevel=2)
warnings.warn(
"Setting zmq Socket attribute {attr} on BackgroundSocket"
" is deprecated since ipykernel 4.3.0"
" use .io_thread.socket.{attr}".format(attr=attr),
DeprecationWarning,
stacklevel=2,
)
setattr(self.io_thread.socket, attr, value)

def send(self, msg, *args, **kwargs):
Expand Down