From: J. Alexander Treuman <jat@spatialrift.net>
Date: Sat, 1 Mar 2008 20:03:47 +0000 (-0500)
Subject: mpd.py: making _getitem return None if no item is returned
X-Git-Tag: v0.2.0~19
X-Git-Url: http://git.kaliko.me/?a=commitdiff_plain;h=94fd67b7f97142bda274187e463320834a58cc15;p=python-musicpd.git

mpd.py: making _getitem return None if no item is returned

update and addid should normally always return a single item, so previously
an exception was raised if we got nothing.  However, when used in a
command_list, only the *last* call to update will return an item.  So
return None instead of raising an exception if we get nothing.
---

diff --git a/mpd.py b/mpd.py
index a5e1877..be8b390 100644
--- a/mpd.py
+++ b/mpd.py
@@ -225,7 +225,7 @@ class MPDClient(object):
     def _getitem(self):
         items = list(self._readitems())
         if len(items) != 1:
-            raise ProtocolError, "Expected 1 item, got %i" % len(items)
+            return
         return items[0][1]
 
     def _getlist(self):