[Pkg-mpd-commits] [python-mpd] 114/262: Revert "more readable exception handling _connect_tcp()"

Simon McVittie smcv at debian.org
Sun May 22 18:16:33 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 c1369ca12b1bf4d347e2efa5a277588be600926e
Author: Jonathan Ballet <jon at multani.info>
Date:   Tue Mar 20 13:18:39 2012 +0700

    Revert "more readable exception handling _connect_tcp()"
    
    This reverts commit da8cb1ae4610c848047dc91856aa25c29d8c6b16.
    
    It turned out that da8cb1 actually changed the API of python-mpd: if an error
    occurred while connecting to the MPD server, MPDClient._connect_tcp() would always
    return 'ConnectionError("getaddrinfo returns an empty list"), even if getaddrinfo()
    actually returned something.
    
    I have no idea how to make getaddrinfo() returns nothing, so it's hard to test at
    the moment.
    
    Conflicts:
    
    	test.py
---
 mpd.py  | 4 ++--
 test.py | 8 +-------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/mpd.py b/mpd.py
index f319993..4c10037 100644
--- a/mpd.py
+++ b/mpd.py
@@ -395,11 +395,11 @@ class MPDClient():
                 err = e
                 if sock is not None:
                     sock.close()
+        if err is not None:
+            raise err
         else:
             raise ConnectionError("getaddrinfo returns an empty list")
 
-        raise err
-
     def connect(self, host, port):
         if self._sock is not None:
             raise ConnectionError("Already connected")
diff --git a/test.py b/test.py
index 442457e..f739f7d 100755
--- a/test.py
+++ b/test.py
@@ -33,7 +33,7 @@ class TestMPDClient(unittest.TestCase):
             self.client.connect(MPD_HOST, MPD_PORT)
             self.idleclient.connect(MPD_HOST, MPD_PORT)
             self.commands = self.client.commands()
-        except (mpd.ConnectionError, SocketError) as e:
+        except SocketError as e:
             raise Exception("Can't connect mpd! Start it or check the configuration: %s" % e)
         if MPD_PASSW != None:
             try:
@@ -129,12 +129,6 @@ class TestMPDClient(unittest.TestCase):
         channels = self.client.channels()
         self.assertNotIn("monty", channels)
 
-    def test_connection_error(self):
-        client2 = mpd.MPDClient()
-        with self.assertRaises(mpd.ConnectionError) as cm:
-            # should never return getaddrinfo
-            client2.connect("255.255.255.255", 6600)
-
     def test_commands_list(self):
         """
         Test if all implemented commands are valid

-- 
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