diff --git a/radicale/server.py b/radicale/server.py index 81436aa..5b3c5bf 100644 --- a/radicale/server.py +++ b/radicale/server.py @@ -40,6 +40,11 @@ if hasattr(socket, "EAI_ADDRFAMILY"): elif hasattr(socket, "EAI_NONAME"): # Windows and BSD don't have a special error code for this COMPAT_EAI_ADDRFAMILY = socket.EAI_NONAME +if hasattr(socket, "EAI_NODATA"): + COMPAT_EAI_NODATA = socket.EAI_NODATA +elif hasattr(socket, "EAI_NONAME"): + # Windows and BSD don't have a special error code for this + COMPAT_EAI_NODATA = socket.EAI_NONAME if hasattr(socket, "IPPROTO_IPV6"): COMPAT_IPPROTO_IPV6 = socket.IPPROTO_IPV6 elif os.name == "nt": @@ -226,7 +231,8 @@ def serve(configuration, shutdown_socket): # macOS: IPv6 address for INET address family e.errno == socket.EAI_NONAME or # Address not for address family - e.errno == COMPAT_EAI_ADDRFAMILY) or + e.errno == COMPAT_EAI_ADDRFAMILY or + e.errno == COMPAT_EAI_NODATA) or # Workaround for PyPy str(e) == "address family mismatched" or # Address family not available (e.g. IPv6 disabled) diff --git a/radicale/tests/test_server.py b/radicale/tests/test_server.py index 7021d75..d097083 100644 --- a/radicale/tests/test_server.py +++ b/radicale/tests/test_server.py @@ -128,8 +128,9 @@ class TestBaseServerRequests(BaseTest): sock.bind((address, 0)) # See ``radicale.server.serve`` assert (isinstance(exc_info.value, socket.gaierror) and - exc_info.value.errno in (socket.EAI_NONAME, - server.COMPAT_EAI_ADDRFAMILY) or + exc_info.value.errno in ( + socket.EAI_NONAME, server.COMPAT_EAI_ADDRFAMILY, + server.COMPAT_EAI_NODATA) or str(exc_info.value) == "address family mismatched" or exc_info.value.errno == errno.EADDRNOTAVAIL) diff --git a/setup.cfg b/setup.cfg index 25d97c2..6e9004e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ norecursedirs = dist .cache .git build Radicale.egg-info .eggs venv [tool:isort] known_standard_library = posixpath -known_third_party = gunicorn,passlib,pkg_resources,pytest,pytest_cov,vobject +known_third_party = defusedxml,passlib,pkg_resources,pytest,vobject [coverage:run] branch = True