equal
deleted
inserted
replaced
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 |