Skip to content

Commit

Permalink
Update some warnings with instructions and version number.
Browse files Browse the repository at this point in the history
I came across this when trying to reproduce an unrelated bug with
someone in an outdated environment, but at least having the version
number will make us more confident when e remove the conditional branch
later.
  • Loading branch information
Carreau committed Sep 1, 2021
1 parent be9d40d commit cf2d56e
Showing 1 changed file with 14 additions and 4 deletions.
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

0 comments on commit cf2d56e

Please sign in to comment.