[Python-checkins] gh-91217: deprecate nntplib (GH-91543)

brettcannon webhook-mailer at python.org
Fri Apr 15 15:33:06 EDT 2022


https://github.com/python/cpython/commit/c9e231de8551ab6d06c92dfa95033150e52d7f1f
commit: c9e231de8551ab6d06c92dfa95033150e52d7f1f
branch: main
author: Brett Cannon <brett at python.org>
committer: brettcannon <brett at python.org>
date: 2022-04-15T12:32:56-07:00
summary:

gh-91217: deprecate nntplib (GH-91543)

files:
A Misc/NEWS.d/next/Library/2022-04-12-20-19-10.gh-issue-91217.acd4h9.rst
M Doc/whatsnew/3.11.rst
M Lib/nntplib.py
M Lib/test/support/socket_helper.py
M Lib/test/test_nntplib.py

diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index ca76efc963719..b5b2a7648c55e 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -875,6 +875,7 @@ Deprecated
   * :mod:`crypt`
   * :mod:`imghdr`
   * :mod:`msilib`
+  * :mod:`nntplib`
 
   (Contributed by Brett Cannon in :issue:`47061`.)
 
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index f6e746e7c95c5..dddea059982be 100644
--- a/Lib/nntplib.py
+++ b/Lib/nntplib.py
@@ -68,6 +68,7 @@
 import collections
 import datetime
 import sys
+import warnings
 
 try:
     import ssl
@@ -85,6 +86,8 @@
            "decode_header",
            ]
 
+warnings._deprecated(__name__, remove=(3, 13))
+
 # maximal line length when calling readline(). This is to prevent
 # reading arbitrary length lines. RFC 3977 limits NNTP line length to
 # 512 characters, including CRLF. We have selected 2048 just to be on
diff --git a/Lib/test/support/socket_helper.py b/Lib/test/support/socket_helper.py
index 0ee7a5d69a1b3..754af181ec922 100644
--- a/Lib/test/support/socket_helper.py
+++ b/Lib/test/support/socket_helper.py
@@ -5,7 +5,7 @@
 import sys
 
 from .. import support
-
+from . import warnings_helper
 
 HOST = "localhost"
 HOSTv4 = "127.0.0.1"
@@ -190,7 +190,7 @@ def get_socket_conn_refused_errs():
 def transient_internet(resource_name, *, timeout=_NOT_SET, errnos=()):
     """Return a context manager that raises ResourceDenied when various issues
     with the internet connection manifest themselves as exceptions."""
-    import nntplib
+    nntplib = warnings_helper.import_deprecated("nntplib")
     import urllib.error
     if timeout is _NOT_SET:
         timeout = support.INTERNET_TIMEOUT
diff --git a/Lib/test/test_nntplib.py b/Lib/test/test_nntplib.py
index 4f0592188f844..9812c05519351 100644
--- a/Lib/test/test_nntplib.py
+++ b/Lib/test/test_nntplib.py
@@ -5,13 +5,13 @@
 import unittest
 import functools
 import contextlib
-import nntplib
 import os.path
 import re
 import threading
 
 from test import support
-from test.support import socket_helper
+from test.support import socket_helper, warnings_helper
+nntplib = warnings_helper.import_deprecated("nntplib")
 from nntplib import NNTP, GroupInfo
 from unittest.mock import patch
 try:
diff --git a/Misc/NEWS.d/next/Library/2022-04-12-20-19-10.gh-issue-91217.acd4h9.rst b/Misc/NEWS.d/next/Library/2022-04-12-20-19-10.gh-issue-91217.acd4h9.rst
new file mode 100644
index 0000000000000..4a74b9d085142
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-04-12-20-19-10.gh-issue-91217.acd4h9.rst
@@ -0,0 +1 @@
+Deprecate nntplib.



More information about the Python-checkins mailing list