Skip to content
Open
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
7 changes: 6 additions & 1 deletion IPython/core/doctb.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ def format_record(self, frame_info: FrameInfo) -> str:

assert frame_info._sd is not None
result = theme_table[self._theme_name].format(
_tokens_filename(True, frame_info.filename, lineno=frame_info.lineno)
_tokens_filename(
True,
frame_info.filename,
lineno=frame_info.lineno,
compress_user=True,
)
)
result += ", " if call else ""
result += f"{call}\n"
Expand Down
9 changes: 6 additions & 3 deletions IPython/core/tbtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def _tokens_filename(
file: str | None,
*,
lineno: int | None = None,
compress_user: bool = True,
) -> TokenStream:
"""
Format filename lines with custom formatting from caching compiler or `File *.py` by default
Expand All @@ -179,6 +180,8 @@ def _tokens_filename(
----------
em: wether bold or not
file : str
compress_user : bool
When True (default), apply ``util_path.compress_user`` to the filename.
"""
Normal = Token.NormalEm if em else Token.Normal
Filename = Token.FilenameEm if em else Token.Filename
Expand All @@ -202,9 +205,9 @@ def _tokens_filename(
(Filename, f", line {lineno}"),
]
else:
name = util_path.compress_user(
py3compat.cast_unicode(file or "", util_path.fs_encoding)
)
name = py3compat.cast_unicode(file or "", util_path.fs_encoding)
if compress_user:
name = util_path.compress_user(name)
if lineno is None:
return [
(Normal, "File "),
Expand Down
17 changes: 14 additions & 3 deletions IPython/core/ultratb.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def _format_list(self, extracted_list: list[Any]) -> list[str]:

item = theme_table[self._theme_name].format(
[(Token.NormalEm if em else Token.Normal, " ")]
+ _tokens_filename(em, filename, lineno=lineno)
+ _tokens_filename(em, filename, lineno=lineno, compress_user=True)
)

# This seem to be only in xmode plain (%run sinpleer), investigate why not share with verbose.
Expand Down Expand Up @@ -332,6 +332,7 @@ def _format_exception_only(
True,
value.filename,
lineno=(None if lineno == "unknown" else lineno),
compress_user=True,
)
+ [(Token, "\n")]
)
Expand Down Expand Up @@ -615,7 +616,12 @@ def format_record(self, frame_info: FrameInfo) -> str:
# fast fallback if file is too long
assert frame_info.filename is not None
level_tokens = (
_tokens_filename(True, frame_info.filename, lineno=frame_info.lineno)
_tokens_filename(
True,
frame_info.filename,
lineno=frame_info.lineno,
compress_user=True,
)
+ [
(Token, ", " if call else ""),
(Token, call),
Expand Down Expand Up @@ -658,7 +664,12 @@ def format_record(self, frame_info: FrameInfo) -> str:
return theme_table[self._theme_name].format(level_tokens + tb_tokens)
else:
result = theme_table[self._theme_name].format(
_tokens_filename(True, frame_info.filename, lineno=frame_info.lineno)
_tokens_filename(
True,
frame_info.filename,
lineno=frame_info.lineno,
compress_user=True,
)
)
result += ", " if call else ""
result += f"{call}\n"
Expand Down
Loading