[Python-checkins] cpython: #6623: Add explicit deprecation warning for ftplib.Netrc.

r.david.murray python-checkins at python.org
Wed Feb 20 00:33:47 CET 2013


http://hg.python.org/cpython/rev/acf247d25f17
changeset: 82268:acf247d25f17
user: R David Murray <rdmurray at bitdance.com>
date: Tue Feb 19 18:32:28 2013 -0500
summary:
 #6623: Add explicit deprecation warning for ftplib.Netrc.
files:
 Lib/ftplib.py | 3 +++
 Lib/test/test_ftplib.py | 13 ++++++++++++-
 Misc/NEWS | 3 +++
 3 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -39,6 +39,7 @@
 import os
 import sys
 import socket
+import warnings
 from socket import _GLOBAL_DEFAULT_TIMEOUT
 
 __all__ = ["FTP","Netrc"]
@@ -953,6 +954,8 @@
 __defacct = None
 
 def __init__(self, filename=None):
+ warnings.warn("This class is deprecated, use the netrc module instead",
+ DeprecationWarning, 2)
 if filename is None:
 if "HOME" in os.environ:
 filename = os.path.join(os.environ["HOME"],
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -985,8 +985,19 @@
 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():
- tests = [TestFTPClass, TestTimeouts]
+ tests = [TestFTPClass, TestTimeouts, TestNetrcDeprecation]
 if support.IPV6_ENABLED:
 tests.append(TestIPv6Environment)
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -260,6 +260,9 @@
 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
 authobject is specified.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /