diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-12 19:15:09 +0100 |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-12 19:15:09 +0100 |
commit | 8e934f00ba8f437df234a984ac74670a3147e6f3 (patch) | |
tree | 66c8acea3b92a3e655dcdd64e8a89a44dd8b7707 /Lib/nntplib.py | |
parent | 85356f5656fb248da853b93986860dffe13bb63e (diff) | |
parent | 91ad6d4dc52ec0de870970ff90bf22f568b6dfb2 (diff) | |
download | cpython-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.py | 18 |
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'): |