diff options
Diffstat (limited to 'Lib/nntplib.py')
-rw-r--r-- | Lib/nntplib.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/Lib/nntplib.py b/Lib/nntplib.py index 32bffd8..2de6ebd 100644 --- a/Lib/nntplib.py +++ b/Lib/nntplib.py @@ -166,7 +166,7 @@ def decode_header(header_str): parts.append(v.decode(enc or 'ascii')) else: parts.append(v) - return ' '.join(parts) + return ''.join(parts) def _parse_overview_fmt(lines): """Parse a list of string representing the response to LIST OVERVIEW.FMT @@ -351,6 +351,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__()). @@ -819,7 +833,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 = [] @@ -837,7 +851,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'): |