Skip to content

Commit 3c6037f

Browse files
authored
Merge pull request #761 from Carreau/better-deprecation
Update some warnings with instructions and version number.
2 parents be9d40d + cf2d56e commit 3c6037f

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ipykernel/iostream.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,17 +252,27 @@ def __getattr__(self, attr):
252252
# don't wrap magic methods
253253
super(BackgroundSocket, self).__getattr__(attr)
254254
if hasattr(self.io_thread.socket, attr):
255-
warnings.warn("Accessing zmq Socket attribute %s on BackgroundSocket" % attr,
256-
DeprecationWarning, stacklevel=2)
255+
warnings.warn(
256+
"Accessing zmq Socket attribute {attr} on BackgroundSocket"
257+
" is deprecated since ipykernel 4.3.0"
258+
" use .io_thread.socket.{attr}".format(attr=attr),
259+
DeprecationWarning,
260+
stacklevel=2,
261+
)
257262
return getattr(self.io_thread.socket, attr)
258263
super(BackgroundSocket, self).__getattr__(attr)
259264

260265
def __setattr__(self, attr, value):
261266
if attr == 'io_thread' or (attr.startswith('__' and attr.endswith('__'))):
262267
super(BackgroundSocket, self).__setattr__(attr, value)
263268
else:
264-
warnings.warn("Setting zmq Socket attribute %s on BackgroundSocket" % attr,
265-
DeprecationWarning, stacklevel=2)
269+
warnings.warn(
270+
"Setting zmq Socket attribute {attr} on BackgroundSocket"
271+
" is deprecated since ipykernel 4.3.0"
272+
" use .io_thread.socket.{attr}".format(attr=attr),
273+
DeprecationWarning,
274+
stacklevel=2,
275+
)
266276
setattr(self.io_thread.socket, attr, value)
267277

268278
def send(self, msg, *args, **kwargs):

0 commit comments

Comments
 (0)