Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/12751.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid keyring logging crashes when pip is run in verbose mode.
4 changes: 4 additions & 0 deletions src/pip/_internal/network/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ def _get_keyring_auth(
try:
return self.keyring_provider.get_auth_info(url, username)
except Exception as exc:
# Log the full exception (with stacktrace) at debug, so it'll only
# show up when running in verbose mode.
logger.debug("Keyring is skipped due to an exception", exc_info=True)
# Always log a shortened version of the exception.
logger.warning(
"Keyring is skipped due to an exception: %s",
str(exc),
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def emit(self, record: logging.LogRecord) -> None:
style: Optional[Style] = None

# If we are given a diagnostic error to present, present it with indentation.
assert isinstance(record.args, tuple)
if getattr(record, "rich", False):
assert isinstance(record.args, tuple)
(rich_renderable,) = record.args
assert isinstance(
rich_renderable, (ConsoleRenderable, RichCast, str)
Expand Down