tests/run-tests.py
branchstable
changeset 47181 6e0af81c43b2
parent 47040 c853bc60c5d6
child 47182 dff19fe2973c
equal deleted inserted replaced
47081:e917fa36fb58 47181:6e0af81c43b2
   260             s.bind(('localhost', port))
   260             s.bind(('localhost', port))
   261         return True
   261         return True
   262     except socket.error as exc:
   262     except socket.error as exc:
   263         if os.name == 'nt' and exc.errno == errno.WSAEACCES:
   263         if os.name == 'nt' and exc.errno == errno.WSAEACCES:
   264             return False
   264             return False
   265         elif exc.errno not in (
   265         elif PYTHON3:
       
   266             # TODO: make a proper exception handler after dropping py2.  This
       
   267             #       works because socket.error is an alias for OSError on py3,
       
   268             #       which is also the baseclass of PermissionError.
       
   269             if isinstance(exc, PermissionError):
       
   270                 return False
       
   271         if exc.errno not in (
   266             errno.EADDRINUSE,
   272             errno.EADDRINUSE,
   267             errno.EADDRNOTAVAIL,
   273             errno.EADDRNOTAVAIL,
   268             errno.EPROTONOSUPPORT,
   274             errno.EPROTONOSUPPORT,
   269         ):
   275         ):
   270             raise
   276             raise