Skip to content

Commit 14a3d93

Browse files
committed
Don't silently fallback to cli
1 parent e6e42de commit 14a3d93

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/pip/_internal/network/auth.py

+13
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,26 @@ def _set_password(self, service_name: str, username: str, password: str) -> None
147147
def get_keyring_provider() -> KeyRingBaseProvider:
148148
# keyring has previously failed and been disabled
149149
if not KEYRING_DISABLED:
150+
# Default to trying to use Python provider
150151
try:
151152
return KeyRingPythonProvider()
152153
except ImportError:
153154
pass
155+
except Exception as exc:
156+
# In the event of an unexpected exception
157+
# we shouldn't fallback silently to the
158+
# CliProvider
159+
logger.warning(
160+
"Keyring is skipped due to an exception: %s",
161+
str(exc),
162+
)
163+
return KeyRingNullProvider()
164+
165+
# Fallback to Cli Provider if `keyring` isn't installed
154166
cli = shutil.which("keyring")
155167
if cli:
156168
return KeyRingCliProvider(cli)
169+
157170
return KeyRingNullProvider()
158171

159172

0 commit comments

Comments
 (0)