Skip to content

Commit 1d578a9

Browse files
committed
do not break apart when no common appdata location is set in registry
1 parent f49a2d9 commit 1d578a9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/pip/_internal/utils/appdirs.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,15 @@ def site_config_dirs(appname: str) -> list[str]:
4444
dirval = _appdirs.site_data_dir(appname, appauthor=False, multipath=True)
4545
return dirval.split(os.pathsep)
4646

47-
dirval = _appdirs.site_config_dir(appname, appauthor=False, multipath=True)
4847
if sys.platform == "win32":
49-
return [dirval]
48+
try:
49+
# Causes FileNotFoundError on attempt to access a registry key that does
50+
# not exist. This should not break apart pip configuration loading.
51+
dirval = _appdirs.site_config_dir(appname, appauthor=False, multipath=True)
52+
return [dirval]
53+
except FileNotFoundError:
54+
return []
5055

5156
# Unix-y system. Look in /etc as well.
57+
dirval = _appdirs.site_config_dir(appname, appauthor=False, multipath=True)
5258
return dirval.split(os.pathsep) + ["/etc"]

0 commit comments

Comments
 (0)