Revert "Merge pull request #8227 from encukou/defensive-get_source"

This reverts commit 67af623d9e, reversing
changes made to aead41e449.
This commit is contained in:
Anthony Sottile 2021-06-03 08:45:01 -07:00
parent 9ad726a9a0
commit 77235e2759
1 changed files with 3 additions and 3 deletions

View File

@ -725,11 +725,11 @@ class FormattedExcinfo:
) -> 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())