mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
#6623: Add explicit deprecation warning for ftplib.Netrc.
This commit is contained in:
parent
8aa164b395
commit
87632f1a9e
3 changed files with 18 additions and 1 deletions
|
@ -39,6 +39,7 @@ python ftplib.py -d localhost -l -p -l
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
|
import warnings
|
||||||
from socket import _GLOBAL_DEFAULT_TIMEOUT
|
from socket import _GLOBAL_DEFAULT_TIMEOUT
|
||||||
|
|
||||||
__all__ = ["FTP","Netrc"]
|
__all__ = ["FTP","Netrc"]
|
||||||
|
@ -953,6 +954,8 @@ class Netrc:
|
||||||
__defacct = None
|
__defacct = None
|
||||||
|
|
||||||
def __init__(self, filename=None):
|
def __init__(self, filename=None):
|
||||||
|
warnings.warn("This class is deprecated, use the netrc module instead",
|
||||||
|
DeprecationWarning, 2)
|
||||||
if filename is None:
|
if filename is None:
|
||||||
if "HOME" in os.environ:
|
if "HOME" in os.environ:
|
||||||
filename = os.path.join(os.environ["HOME"],
|
filename = os.path.join(os.environ["HOME"],
|
||||||
|
|
|
@ -985,8 +985,19 @@ class TestTimeouts(TestCase):
|
||||||
ftp.close()
|
ftp.close()
|
||||||
|
|
||||||
|
|
||||||
|
class TestNetrcDeprecation(TestCase):
|
||||||
|
|
||||||
|
def test_deprecation(self):
|
||||||
|
with support.temp_cwd(), support.EnvironmentVarGuard() as env:
|
||||||
|
env['HOME'] = os.getcwd()
|
||||||
|
open('.netrc', 'w').close()
|
||||||
|
with self.assertWarns(DeprecationWarning):
|
||||||
|
ftplib.Netrc()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
tests = [TestFTPClass, TestTimeouts]
|
tests = [TestFTPClass, TestTimeouts, TestNetrcDeprecation]
|
||||||
if support.IPV6_ENABLED:
|
if support.IPV6_ENABLED:
|
||||||
tests.append(TestIPv6Environment)
|
tests.append(TestIPv6Environment)
|
||||||
|
|
||||||
|
|
|
@ -260,6 +260,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #6623: Added explicit DeprecationWarning for ftplib.netrc, which has
|
||||||
|
been deprecated and undocumented for a long time.
|
||||||
|
|
||||||
- Issue #13700: Fix byte/string handling in imaplib authentication when an
|
- Issue #13700: Fix byte/string handling in imaplib authentication when an
|
||||||
authobject is specified.
|
authobject is specified.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue