From 74eff57815a3308a1fafd14c1ebbcdb8714bec75 Mon Sep 17 00:00:00 2001 From: "J. Alexander Treuman" Date: Mon, 30 Jun 2008 15:14:10 -0400 Subject: [PATCH] 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. --- mpd.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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) -- 2.39.5