summaryrefslogtreecommitdiff
path: root/Lib/nntplib.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-02-12 19:15:09 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2012-02-12 19:15:09 +0100
commit8e934f00ba8f437df234a984ac74670a3147e6f3 (patch)
tree66c8acea3b92a3e655dcdd64e8a89a44dd8b7707 /Lib/nntplib.py
parent85356f5656fb248da853b93986860dffe13bb63e (diff)
parent91ad6d4dc52ec0de870970ff90bf22f568b6dfb2 (diff)
downloadcpython-8e934f00ba8f437df234a984ac74670a3147e6f3.tar.gz
Issue #10287: nntplib now queries the server's CAPABILITIES again after authenticating (since the result may change, according to RFC 4643).
Patch by Hynek Schlawack.
Diffstat (limited to 'Lib/nntplib.py')
-rw-r--r--Lib/nntplib.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index 6b0150d3cf..7ebc6215fb 100644
--- a/Lib/nntplib.py
+++ b/Lib/nntplib.py
@@ -346,6 +346,20 @@ class _NNTPBase:
# Log in and encryption setup order is left to subclasses.
self.authenticated = False
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *args):
+ is_connected = lambda: hasattr(self, "file")
+ if is_connected():
+ try:
+ self.quit()
+ except (socket.error, EOFError):
+ pass
+ finally:
+ if is_connected():
+ self._close()
+
def getwelcome(self):
"""Get the welcome message from the server
(this is read and squirreled away by __init__()).
@@ -814,7 +828,7 @@ class _NNTPBase:
- list: list of (name,title) strings"""
warnings.warn("The XGTITLE extension is not actively used, "
"use descriptions() instead",
- PendingDeprecationWarning, 2)
+ DeprecationWarning, 2)
line_pat = re.compile('^([^ \t]+)[ \t]+(.*)$')
resp, raw_lines = self._longcmdstring('XGTITLE ' + group, file)
lines = []
@@ -832,7 +846,7 @@ class _NNTPBase:
path: directory path to article
"""
warnings.warn("The XPATH extension is not actively used",
- PendingDeprecationWarning, 2)
+ DeprecationWarning, 2)
resp = self._shortcmd('XPATH {0}'.format(id))
if not resp.startswith('223'):