Skip to content

Commit bb9683d

Browse files
authored
Merge pull request #8729 from asottile/revert-traceback-frame
Revert "Merge pull request #8227 from encukou/defensive-get_source"
2 parents 9ad726a + 77235e2 commit bb9683d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/_pytest/_code/code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,11 @@ def get_source(
725725
) -> List[str]:
726726
"""Return formatted and marked up source lines."""
727727
lines = []
728-
if source is not None and line_index < 0:
729-
line_index += len(source.lines)
730-
if source is None or line_index >= len(source.lines) or line_index < 0:
728+
if source is None or line_index >= len(source.lines):
731729
source = Source("???")
732730
line_index = 0
731+
if line_index < 0:
732+
line_index += len(source)
733733
space_prefix = " "
734734
if short:
735735
lines.append(space_prefix + source.lines[line_index].strip())

0 commit comments

Comments
 (0)