From: J. Alexander Treuman Date: Thu, 3 Apr 2008 04:23:36 +0000 (-0400) Subject: mpd.py: catch all exceptions raised by _hello() X-Git-Tag: v0.2.0~1 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=8ab007756785772039ccbc4b650366e4a191bd58;p=python-musicpd.git mpd.py: catch all exceptions raised by _hello() 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. --- diff --git a/mpd.py b/mpd.py index 8b70f4a..5acc575 100644 --- a/mpd.py +++ b/mpd.py @@ -310,7 +310,7 @@ class MPDClient(object): self._wfile = self._sock.makefile("wb") try: self._hello() - except (socket.error, MPDError): + except: self.disconnect() raise