Skip to content

Commit

Permalink
Merge pull request #8729 from asottile/revert-traceback-frame
Browse files Browse the repository at this point in the history
Revert "Merge pull request #8227 from encukou/defensive-get_source"
  • Loading branch information
asottile committed Jun 3, 2021
2 parents 9ad726a + 77235e2 commit bb9683d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/_pytest/_code/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,11 @@ def get_source(
) -> List[str]:
"""Return formatted and marked up source lines."""
lines = []
if source is not None and line_index < 0:
line_index += len(source.lines)
if source is None or line_index >= len(source.lines) or line_index < 0:
if source is None or line_index >= len(source.lines):
source = Source("???")
line_index = 0
if line_index < 0:
line_index += len(source)
space_prefix = " "
if short:
lines.append(space_prefix + source.lines[line_index].strip())
Expand Down

0 comments on commit bb9683d

Please sign in to comment.