From 7b9b9b2333fa7ac232bdc5e48569e2f784db3bd5 2014-03-20 21:51:27 From: Brian E. Granger Date: 2014-03-20 21:51:27 Subject: [PATCH] Merge pull request #5390 from minrk/finish-5333 finish PR #5333 --- diff --git a/IPython/html/utils.py b/IPython/html/utils.py index 52988d5..806ac94 100644 --- a/IPython/html/utils.py +++ b/IPython/html/utils.py @@ -102,10 +102,22 @@ def is_hidden(abs_path, abs_root=''): if any(part.startswith('.') for part in inside_root.split(os.sep)): return True + # check that dirs can be listed + # may fail on Windows junctions or non-user-readable dirs + if os.path.isdir(abs_path): + try: + os.listdir(abs_path) + except OSError: + return True + # check UF_HIDDEN on any location up to root path = abs_path while path and path.startswith(abs_root) and path != abs_root: - st = os.stat(path) + try: + # may fail on Windows junctions + st = os.stat(path) + except OSError: + return True if getattr(st, 'st_flags', 0) & UF_HIDDEN: return True path = os.path.dirname(path)