Skip to content

Commit 7aa6891

Browse files
embraySteven Silvester
authored and
Steven Silvester
committed
Workaround for wrong errno on socket bind permission errors on Cygwin.
1 parent b5b44eb commit 7aa6891

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

notebook/notebookapp.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1725,14 +1725,21 @@ def _bind_http_server_tcp(self):
17251725
try:
17261726
self.http_server.listen(port, self.ip)
17271727
except socket.error as e:
1728+
eacces = (errno.EACCES, getattr(errno, 'WSAEACCES', errno.EACCES))
1729+
if sys.platform == 'cygwin':
1730+
# Cygwin has a bug that causes EPERM to be returned in this
1731+
# case instead of EACCES:
1732+
# https://cygwin.com/ml/cygwin/2019-04/msg00160.html
1733+
eacces += (errno.EPERM,)
1734+
17281735
if e.errno == errno.EADDRINUSE:
17291736
if self.port_retries:
17301737
self.log.info(_('The port %i is already in use, trying another port.') % port)
17311738
else:
17321739
self.log.info(_('The port %i is already in use.') % port)
17331740
continue
1734-
elif e.errno in (errno.EACCES, getattr(errno, 'WSAEACCES', errno.EACCES)):
1735-
self.log.warning(_("Permission to listen on port %i denied.") % port)
1741+
elif e.errno in eacces:
1742+
self.log.warning(_("Permission to listen on port %i denied") % port)
17361743
continue
17371744
else:
17381745
raise

0 commit comments

Comments
 (0)