diff options
author | Giampaolo RodolĂ <g.rodola@gmail.com> | 2011-02-25 22:28:24 (GMT) |
---|---|---|
committer | Giampaolo RodolĂ <g.rodola@gmail.com> | 2011-02-25 22:28:24 (GMT) |
commit | 95bcb93041417efb7166fc1715c1f9db66a54d81 (patch) | |
tree | c322622be1a87cf47e2acd238927d3070f5ac959 /Lib/poplib.py | |
parent | 103a6d6cd6eb5bf894890f0126547e64ff20a5c9 (diff) | |
download | cpython-95bcb93041417efb7166fc1715c1f9db66a54d81.zip cpython-95bcb93041417efb7166fc1715c1f9db66a54d81.tar.gz cpython-95bcb93041417efb7166fc1715c1f9db66a54d81.tar.bz2 |
Issue 11291: poplib suppresses errors on QUIT.
Diffstat (limited to 'Lib/poplib.py')
-rw-r--r-- | Lib/poplib.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Lib/poplib.py b/Lib/poplib.py index 84ea88d..d42d9dd 100644 --- a/Lib/poplib.py +++ b/Lib/poplib.py @@ -250,15 +250,18 @@ class POP3: def quit(self): """Signoff: commit changes on server, unlock mailbox, close connection.""" - try: - resp = self._shortcmd('QUIT') - except error_proto as val: - resp = val - self.file.close() - self.sock.close() - del self.file, self.sock + resp = self._shortcmd('QUIT') + self.close() return resp + def close(self): + """Close the connection without assuming anything about it.""" + if self.file is not None: + self.file.close() + if self.sock is not None: + self.sock.close() + self.file = self.sock = None + #__del__ = quit |