From cf2d56ecbe92bd557842137b9e9689fad1eedac3 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Wed, 1 Sep 2021 10:26:43 -0700 Subject: [PATCH] Update some warnings with instructions and version number. 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. --- ipykernel/iostream.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ipykernel/iostream.py b/ipykernel/iostream.py index 56e6d8a15..2f760b8dd 100644 --- a/ipykernel/iostream.py +++ b/ipykernel/iostream.py @@ -252,8 +252,13 @@ 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) @@ -261,8 +266,13 @@ 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):