Skip to content

Commit 1c506c0

Browse files
authored
Merge pull request #286 from minrk/no-sticky-darwin
Soften and suppress warnings about sticky bits
2 parents af1b570 + 02bd877 commit 1c506c0

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

jupyter_client/connect.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from __future__ import absolute_import
1212

13+
import errno
1314
import glob
1415
import json
1516
import os
@@ -148,14 +149,19 @@ def write_connection_file(fname=None, shell_port=0, iopub_port=0, stdin_port=0,
148149
new_permissions = permissions | stat.S_ISVTX
149150
if new_permissions != permissions:
150151
try:
151-
os.chmod(path, permissions)
152+
os.chmod(path, new_permissions)
152153
except OSError as e:
153-
# failed to set sticky bit,
154-
# probably not a big deal
155-
warnings.warn(
156-
"Failed to set sticky bit on %r: %s" % (path, e),
157-
RuntimeWarning,
158-
)
154+
if e.errno == errno.EPERM and path == runtime_dir:
155+
# suppress permission errors setting sticky bit on runtime_dir,
156+
# which we may not own.
157+
pass
158+
else:
159+
# failed to set sticky bit, probably not a big deal
160+
warnings.warn(
161+
"Failed to set sticky bit on %r: %s"
162+
"\nProbably not a big deal, but runtime files may be cleaned up periodically." % (path, e),
163+
RuntimeWarning,
164+
)
159165

160166
return fname, cfg
161167

0 commit comments

Comments
 (0)