Skip to content

Commit c9e231d

Browse files
authored
gh-91217: deprecate nntplib (GH-91543)
1 parent ea2ae02 commit c9e231d

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

Doc/whatsnew/3.11.rst

+1
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,7 @@ Deprecated
875875
* :mod:`crypt`
876876
* :mod:`imghdr`
877877
* :mod:`msilib`
878+
* :mod:`nntplib`
878879

879880
(Contributed by Brett Cannon in :issue:`47061`.)
880881

Lib/nntplib.py

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import collections
6969
import datetime
7070
import sys
71+
import warnings
7172

7273
try:
7374
import ssl
@@ -85,6 +86,8 @@
8586
"decode_header",
8687
]
8788

89+
warnings._deprecated(__name__, remove=(3, 13))
90+
8891
# maximal line length when calling readline(). This is to prevent
8992
# reading arbitrary length lines. RFC 3977 limits NNTP line length to
9093
# 512 characters, including CRLF. We have selected 2048 just to be on

Lib/test/support/socket_helper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sys
66

77
from .. import support
8-
8+
from . import warnings_helper
99

1010
HOST = "localhost"
1111
HOSTv4 = "127.0.0.1"
@@ -190,7 +190,7 @@ def get_socket_conn_refused_errs():
190190
def transient_internet(resource_name, *, timeout=_NOT_SET, errnos=()):
191191
"""Return a context manager that raises ResourceDenied when various issues
192192
with the internet connection manifest themselves as exceptions."""
193-
import nntplib
193+
nntplib = warnings_helper.import_deprecated("nntplib")
194194
import urllib.error
195195
if timeout is _NOT_SET:
196196
timeout = support.INTERNET_TIMEOUT

Lib/test/test_nntplib.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
import unittest
66
import functools
77
import contextlib
8-
import nntplib
98
import os.path
109
import re
1110
import threading
1211

1312
from test import support
14-
from test.support import socket_helper
13+
from test.support import socket_helper, warnings_helper
14+
nntplib = warnings_helper.import_deprecated("nntplib")
1515
from nntplib import NNTP, GroupInfo
1616
from unittest.mock import patch
1717
try:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate nntplib.

0 commit comments

Comments
 (0)