I normally consider it bad form to catch all exceptions, since it can
result in lost KeyboardInterrupts. But in this case we re-raise the
exception after cleaning up, so it's ok.
While _hello() itself only raises socket.error or an MPDError subclass, a
KeyboardInterrupt would previously go uncaught. Since the connection was
never cleaned up, it could be left in an unusable state. So just
disconnect on all exceptions instead.
self._wfile = self._sock.makefile("wb")
try:
self._hello()
- except (socket.error, MPDError):
+ except:
self.disconnect()
raise