Fix integrated server on android

This commit is contained in:
Unrud 2020-04-09 22:01:55 +02:00
parent 9c622b57d5
commit 8ca01a4989
3 changed files with 11 additions and 4 deletions

View File

@ -40,6 +40,11 @@ if hasattr(socket, "EAI_ADDRFAMILY"):
elif hasattr(socket, "EAI_NONAME"): elif hasattr(socket, "EAI_NONAME"):
# Windows and BSD don't have a special error code for this # Windows and BSD don't have a special error code for this
COMPAT_EAI_ADDRFAMILY = socket.EAI_NONAME 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"): if hasattr(socket, "IPPROTO_IPV6"):
COMPAT_IPPROTO_IPV6 = socket.IPPROTO_IPV6 COMPAT_IPPROTO_IPV6 = socket.IPPROTO_IPV6
elif os.name == "nt": elif os.name == "nt":
@ -226,7 +231,8 @@ def serve(configuration, shutdown_socket):
# macOS: IPv6 address for INET address family # macOS: IPv6 address for INET address family
e.errno == socket.EAI_NONAME or e.errno == socket.EAI_NONAME or
# Address not for address family # 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 # Workaround for PyPy
str(e) == "address family mismatched" or str(e) == "address family mismatched" or
# Address family not available (e.g. IPv6 disabled) # Address family not available (e.g. IPv6 disabled)

View File

@ -128,8 +128,9 @@ class TestBaseServerRequests(BaseTest):
sock.bind((address, 0)) sock.bind((address, 0))
# See ``radicale.server.serve`` # See ``radicale.server.serve``
assert (isinstance(exc_info.value, socket.gaierror) and assert (isinstance(exc_info.value, socket.gaierror) and
exc_info.value.errno in (socket.EAI_NONAME, exc_info.value.errno in (
server.COMPAT_EAI_ADDRFAMILY) or socket.EAI_NONAME, server.COMPAT_EAI_ADDRFAMILY,
server.COMPAT_EAI_NODATA) or
str(exc_info.value) == "address family mismatched" or str(exc_info.value) == "address family mismatched" or
exc_info.value.errno == errno.EADDRNOTAVAIL) exc_info.value.errno == errno.EADDRNOTAVAIL)

View File

@ -10,7 +10,7 @@ norecursedirs = dist .cache .git build Radicale.egg-info .eggs venv
[tool:isort] [tool:isort]
known_standard_library = posixpath 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] [coverage:run]
branch = True branch = True