gh-91217: deprecate nntplib (GH-91543)

This commit is contained in:
Brett Cannon 2022-04-15 12:32:56 -07:00 committed by GitHub
parent ea2ae02607
commit c9e231de85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 4 deletions

View file

@ -875,6 +875,7 @@ Deprecated
* :mod:`crypt` * :mod:`crypt`
* :mod:`imghdr` * :mod:`imghdr`
* :mod:`msilib` * :mod:`msilib`
* :mod:`nntplib`
(Contributed by Brett Cannon in :issue:`47061`.) (Contributed by Brett Cannon in :issue:`47061`.)

View file

@ -68,6 +68,7 @@ import socket
import collections import collections
import datetime import datetime
import sys import sys
import warnings
try: try:
import ssl import ssl
@ -85,6 +86,8 @@ __all__ = ["NNTP",
"decode_header", "decode_header",
] ]
warnings._deprecated(__name__, remove=(3, 13))
# maximal line length when calling readline(). This is to prevent # maximal line length when calling readline(). This is to prevent
# reading arbitrary length lines. RFC 3977 limits NNTP line length to # reading arbitrary length lines. RFC 3977 limits NNTP line length to
# 512 characters, including CRLF. We have selected 2048 just to be on # 512 characters, including CRLF. We have selected 2048 just to be on

View file

@ -5,7 +5,7 @@ import unittest
import sys import sys
from .. import support from .. import support
from . import warnings_helper
HOST = "localhost" HOST = "localhost"
HOSTv4 = "127.0.0.1" HOSTv4 = "127.0.0.1"
@ -190,7 +190,7 @@ _NOT_SET = object()
def transient_internet(resource_name, *, timeout=_NOT_SET, errnos=()): def transient_internet(resource_name, *, timeout=_NOT_SET, errnos=()):
"""Return a context manager that raises ResourceDenied when various issues """Return a context manager that raises ResourceDenied when various issues
with the internet connection manifest themselves as exceptions.""" with the internet connection manifest themselves as exceptions."""
import nntplib nntplib = warnings_helper.import_deprecated("nntplib")
import urllib.error import urllib.error
if timeout is _NOT_SET: if timeout is _NOT_SET:
timeout = support.INTERNET_TIMEOUT timeout = support.INTERNET_TIMEOUT

View file

@ -5,13 +5,13 @@ import textwrap
import unittest import unittest
import functools import functools
import contextlib import contextlib
import nntplib
import os.path import os.path
import re import re
import threading import threading
from test import support 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 nntplib import NNTP, GroupInfo
from unittest.mock import patch from unittest.mock import patch
try: try:

View file

@ -0,0 +1 @@
Deprecate nntplib.