Skip to content

Commit 3fd64db

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

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

news/13567.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Do not break with FileNotFoundError when loading site-config-dir location from windows registry (CSIDL_COMMON_APPDATA).

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)