]> kaliko git repositories - python-musicpd.git/commitdiff
mpd.py: catch all exceptions raised by _hello()
authorJ. Alexander Treuman <jat@spatialrift.net>
Thu, 3 Apr 2008 04:23:36 +0000 (00:23 -0400)
committerJ. Alexander Treuman <jat@spatialrift.net>
Thu, 3 Apr 2008 04:23:36 +0000 (00:23 -0400)
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

diff --git a/mpd.py b/mpd.py
index 8b70f4aa955ffcfcf2bda81f85c642879238e76b..5acc575e8794c661dfe36bcd18274d166f511e7b 100644 (file)
--- 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