Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e1aadc2

Browse files
committed
fix test
1 parent f48986a commit e1aadc2

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

IPython/core/ultratb.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,8 +841,17 @@ def get_records(self, etb: TracebackType, context: int, tb_offset: int) -> Any:
841841
cf = cf.tb_next
842842
continue
843843
frame_len = get_line_number_of_frame(cf.tb_frame)
844+
if frame_len == 0:
845+
# File not found or not a .py file (e.g. <string> from
846+
# exec()). Check if source is actually available; if not,
847+
# force the fast path so that FrameInfo's "Could not get
848+
# source" fallback is rendered.
849+
try:
850+
inspect.getsourcelines(cf.tb_frame)
851+
except OSError:
852+
frame_len = FAST_THRESHOLD + 1
844853
except OSError:
845-
frame_len = 0
854+
frame_len = FAST_THRESHOLD + 1
846855
assert cf is not None # narrowing for mypy; guarded by while condition
847856
tbs.append((cf, frame_len))
848857
cf = cf.tb_next

0 commit comments

Comments
 (0)