[Pkg-mpd-commits] [python-mpd] 23/262: mpd.py: raise ConnectionError on EOF

Simon McVittie smcv at debian.org
Sun May 22 18:16:20 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch upstream
in repository python-mpd.

commit ecdbc2e2d41d0e4545d6e4c68e9fd00e0f6129c3
Author: J. Alexander Treuman <jat at spatialrift.net>
Date:   Sat Mar 22 23:16:31 2008 -0400

    mpd.py: raise ConnectionError on EOF
---
 mpd.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/mpd.py b/mpd.py
index be8b390..e16c8b8 100644
--- a/mpd.py
+++ b/mpd.py
@@ -26,6 +26,9 @@ NEXT = "list_OK"
 class MPDError(Exception):
     pass
 
+class ConnectionError(MPDError):
+    pass
+
 class ProtocolError(MPDError):
     pass
 
@@ -141,7 +144,10 @@ class MPDClient(object):
         self._writeline(" ".join(parts))
 
     def _readline(self):
-        line = self._sockfile.readline().rstrip("\n")
+        line = self._sockfile.readline()
+        if not line.endswith("\n"):
+            raise ConnectionError, "Connection lost while reading line"
+        line = line.rstrip("\n")
         if line.startswith(ERROR_PREFIX):
             error = line[len(ERROR_PREFIX):].strip()
             raise CommandError, error
@@ -259,7 +265,9 @@ class MPDClient(object):
         return self._wrapiterator(self._readcommandlist())
 
     def _hello(self):
-        line = self._sockfile.readline().rstrip("\n")
+        line = self._sockfile.readline()
+        if not line.endswith("\n"):
+            raise ConnectionError, "Connection lost while reading MPD hello"
         if not line.startswith(HELLO_PREFIX):
             raise ProtocolError, "Got invalid MPD hello: '%s'" % line
         self.mpd_version = line[len(HELLO_PREFIX):].strip()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mpd/python-mpd.git



More information about the Pkg-mpd-commits mailing list