def safe_listdir(path):
try:<EOL><INDENT>return os.listdir(path)<EOL><DEDENT>except (PermissionError, NotADirectoryError):<EOL><INDENT>pass<EOL><DEDENT>except OSError as e:<EOL><INDENT>ignorable = (<EOL>e.errno in (errno.ENOTDIR, errno.EACCES, errno.ENOENT)<EOL>or getattr(e, "<STR_LIT>", None) == <NUM_LIT><EOL>)<EOL>if not ignorable:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>return ()<EOL>
Attempt to list contents of path, but suppress some exceptions.