From 8ab007756785772039ccbc4b650366e4a191bd58 Mon Sep 17 00:00:00 2001 From: "J. Alexander Treuman" Date: Thu, 3 Apr 2008 00:23:36 -0400 Subject: [PATCH] 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. --- mpd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.39.2