[Python-checkins] gh-91217: deprecate telnetlib (GH-91958)

brettcannon webhook-mailer at python.org
Tue Apr 26 13:45:19 EDT 2022


https://github.com/python/cpython/commit/1af871eeee4a01cc21a6960d087e9ab8ce4c9f4d
commit: 1af871eeee4a01cc21a6960d087e9ab8ce4c9f4d
branch: main
author: Brett Cannon <brett at python.org>
committer: brettcannon <brett at python.org>
date: 2022-04-26T10:45:08-07:00
summary:

gh-91217: deprecate telnetlib (GH-91958)

files:
A Misc/NEWS.d/next/Library/2022-04-17-12-41-52.gh-issue-91217.3wnHSX.rst
M Doc/whatsnew/3.11.rst
M Lib/telnetlib.py
M Lib/test/test_telnetlib.py

diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 8f0d3c7c7099a..b812658d5e91e 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -1069,6 +1069,7 @@ Deprecated
   * :mod:`sndhdr`
   * :mod:`spwd`
   * :mod:`sunau`
+  * :mod:`telnetlib`
 
   (Contributed by Brett Cannon in :issue:`47061`.)
 
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py
index ae88ea594746f..62d636129853a 100644
--- a/Lib/telnetlib.py
+++ b/Lib/telnetlib.py
@@ -37,6 +37,9 @@
 import socket
 import selectors
 from time import monotonic as _time
+import warnings
+
+warnings._deprecated(__name__, remove=(3, 13))
 
 __all__ = ["Telnet"]
 
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py
index b50df1459d1f4..a9cade2ee466f 100644
--- a/Lib/test/test_telnetlib.py
+++ b/Lib/test/test_telnetlib.py
@@ -1,15 +1,16 @@
 import socket
 import selectors
-import telnetlib
 import threading
 import contextlib
 
 from test import support
-from test.support import socket_helper
+from test.support import socket_helper, warnings_helper
 import unittest
 
 support.requires_working_socket(module=True)
 
+telnetlib = warnings_helper.import_deprecated('telnetlib')
+
 HOST = socket_helper.HOST
 
 def server(evt, serv):
diff --git a/Misc/NEWS.d/next/Library/2022-04-17-12-41-52.gh-issue-91217.3wnHSX.rst b/Misc/NEWS.d/next/Library/2022-04-17-12-41-52.gh-issue-91217.3wnHSX.rst
new file mode 100644
index 0000000000000..6c4acc7924332
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-04-17-12-41-52.gh-issue-91217.3wnHSX.rst
@@ -0,0 +1 @@
+Deprecate the telnetlib module.



More information about the Python-checkins mailing list