Skip to content

Commit

Permalink
catch os.getcwd
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Feb 11, 2024
1 parent 289ad77 commit d1e5683
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/black/files.py
Expand Up @@ -263,17 +263,16 @@ def resolves_outside_root_or_cannot_stat(
Returns whether the path is a symbolic link that points outside the
root directory. Also returns True if we failed to resolve the path.
"""
if sys.version_info < (3, 8, 6):
path = path.absolute() # https://bugs.python.org/issue33660
try:
if sys.version_info < (3, 8, 6):
path = path.absolute() # https://bugs.python.org/issue33660
resolved_path = path.resolve()
return get_root_relative_path(resolved_path, root, report) is None
except OSError as e:
if report:
report.path_ignored(path, f"cannot be read because {e}")
return True

return get_root_relative_path(resolved_path, root, report) is None


def get_root_relative_path(
path: Path,
Expand Down

0 comments on commit d1e5683

Please sign in to comment.