Skip to content

Commit

Permalink
Make this code path more safe to prevent stack trace/regression.
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius authored and oz123 committed Sep 29, 2024
1 parent 7b8ba87 commit fa08ff5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pipenv/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@

def unstyle(text: str) -> str:
"""Remove all styles from the given text."""
styled_text = Text.from_markup(text)
stripped_text = styled_text.strip_styles()
return stripped_text.to_plain_text()
try:
styled_text = Text.from_markup(text)
stripped_text = styled_text.strip_styles()
return stripped_text.plain
except AttributeError:
# Fallback if the expected methods are not available
return str(text)


KnownException = namedtuple(
Expand Down

0 comments on commit fa08ff5

Please sign in to comment.