mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Fix exception when /etc/paths{,.d} is not readable on macOS
It may be present but not readable. This may occur when executing in a sandbox that does not permit access.
This commit is contained in:
@@ -670,7 +670,7 @@ def system_paths_on_macos() -> tuple[str, ...]:
|
|||||||
def add_from_file(x: str) -> None:
|
def add_from_file(x: str) -> None:
|
||||||
try:
|
try:
|
||||||
f = open(x)
|
f = open(x)
|
||||||
except FileNotFoundError:
|
except (FileNotFoundError, PermissionError):
|
||||||
return
|
return
|
||||||
with f:
|
with f:
|
||||||
for line in f:
|
for line in f:
|
||||||
@@ -681,7 +681,7 @@ def system_paths_on_macos() -> tuple[str, ...]:
|
|||||||
entries.append(line)
|
entries.append(line)
|
||||||
try:
|
try:
|
||||||
files = os.listdir('/etc/paths.d')
|
files = os.listdir('/etc/paths.d')
|
||||||
except FileNotFoundError:
|
except (FileNotFoundError, PermissionError):
|
||||||
files = []
|
files = []
|
||||||
for name in sorted(files):
|
for name in sorted(files):
|
||||||
add_from_file(os.path.join('/etc/paths.d', name))
|
add_from_file(os.path.join('/etc/paths.d', name))
|
||||||
|
|||||||
Reference in New Issue
Block a user