This commit is contained in:
Will McGugan 2021-12-31 10:48:12 +00:00
parent 18cccde154
commit ca7d0e695c
2 changed files with 19 additions and 13 deletions

View File

@ -1078,18 +1078,21 @@ class Text(JupyterMixin):
break
start_line_no = (lower_bound + upper_bound) // 2
end_line_no = lower_bound = start_line_no
upper_bound = line_count
if span_end < line_end:
end_line_no = start_line_no
else:
end_line_no = lower_bound = start_line_no
upper_bound = line_count
while True:
line_start, line_end = line_ranges[end_line_no]
if span_end < line_start:
upper_bound = end_line_no - 1
elif span_end > line_end:
lower_bound = end_line_no + 1
else:
break
end_line_no = (lower_bound + upper_bound) // 2
while True:
line_start, line_end = line_ranges[end_line_no]
if span_end < line_start:
upper_bound = end_line_no - 1
elif span_end > line_end:
lower_bound = end_line_no + 1
else:
break
end_line_no = (lower_bound + upper_bound) // 2
for line_no in range(start_line_no, end_line_no + 1):
line_start, line_end = line_ranges[line_no]

View File

@ -138,12 +138,12 @@ def install(
# if wihin ipython, use customized traceback
ip = get_ipython() # type: ignore
ipy_excepthook_closure(ip)
return sys.excepthook # type: ignore # more strict signature that mypy can't interpret
return sys.excepthook
except Exception:
# otherwise use default system hook
old_excepthook = sys.excepthook
sys.excepthook = excepthook
return old_excepthook # type: ignore # more strict signature that mypy can't interpret
return old_excepthook
@dataclass
@ -246,6 +246,9 @@ class Traceback:
self.suppress: Sequence[str] = []
for suppress_entity in suppress:
if not isinstance(suppress_entity, str):
assert (
suppress_entity.__file__ is not None
), f"{suppress_entity!r} must be a module with '__file__' attribute"
path = os.path.dirname(suppress_entity.__file__)
else:
path = suppress_entity