comparison tests/run-tests.py @ 49875:a77c1375c316

run-tests: drop a workaround for python2 The problem is only on python3, but the awkward handling was because python2 didn't have this exception type. I've sporadically seen it running in WSL, but no clue what it means.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 19 Jul 2022 16:46:37 -0400
parents a2356e15200a
children afa9d73780e1
comparison
equal deleted inserted replaced
49874:cd3b8fd1d3eb 49875:a77c1375c316
270 family = socket.AF_INET 270 family = socket.AF_INET
271 try: 271 try:
272 with contextlib.closing(socket.socket(family, socket.SOCK_STREAM)) as s: 272 with contextlib.closing(socket.socket(family, socket.SOCK_STREAM)) as s:
273 s.bind(('localhost', port)) 273 s.bind(('localhost', port))
274 return True 274 return True
275 except PermissionError:
276 return False
275 except socket.error as exc: 277 except socket.error as exc:
276 if WINDOWS and exc.errno == errno.WSAEACCES: 278 if WINDOWS and exc.errno == errno.WSAEACCES:
277 return False
278 # TODO: make a proper exception handler after dropping py2. This
279 # works because socket.error is an alias for OSError on py3,
280 # which is also the baseclass of PermissionError.
281 elif isinstance(exc, PermissionError):
282 return False 279 return False
283 if exc.errno not in ( 280 if exc.errno not in (
284 errno.EADDRINUSE, 281 errno.EADDRINUSE,
285 errno.EADDRNOTAVAIL, 282 errno.EADDRNOTAVAIL,
286 errno.EPROTONOSUPPORT, 283 errno.EPROTONOSUPPORT,