From: J. Alexander Treuman Date: Mon, 30 Jun 2008 19:14:10 +0000 (-0400) Subject: mpd.py: adding a workaround for systems missing socket.AI_ADDRCONFIG X-Git-Tag: v0.2.1~2 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=74eff57815a3308a1fafd14c1ebbcdb8714bec75;p=python-musicpd.git mpd.py: adding a workaround for systems missing socket.AI_ADDRCONFIG Python on Windows doesn't define socket.AI_ADDRCONFIG. This is likely because the flag is only supported by getaddrinfo() on Vista or later. --- diff --git a/mpd.py b/mpd.py index 5acc575..384f856 100644 --- a/mpd.py +++ b/mpd.py @@ -291,9 +291,13 @@ class MPDClient(object): if self._sock: raise ConnectionError("Already connected") msg = "getaddrinfo returns an empty list" + try: + flags = socket.AI_ADDRCONFIG + except AttributeError: + flags = 0 for res in socket.getaddrinfo(host, port, socket.AF_UNSPEC, socket.SOCK_STREAM, socket.IPPROTO_TCP, - socket.AI_ADDRCONFIG): + flags): af, socktype, proto, canonname, sa = res try: self._sock = socket.socket(af, socktype, proto)