Skip to content

Commit c720a3f

Browse files
committed
undo unnecessary merge
1 parent 99a863a commit c720a3f

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

Lib/traceback.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -400,32 +400,18 @@ def walk_tb(tb):
400400
tb = tb.tb_next
401401

402402

403-
def _get_tb_position(tb):
404-
positions = _get_code_position(tb.tb_frame.f_code, tb.tb_lasti)
405-
# Yield tb_lineno when co_positions does not have a line number to
406-
# maintain behavior with walk_tb.
407-
if positions[0] is None:
408-
return tb.tb_frame, (tb.tb_lineno, ) + positions[1:]
409-
return tb.tb_frame, positions
410-
411-
412-
def _walk_tb_with_full_positions(tb, _seen=None):
403+
def _walk_tb_with_full_positions(tb):
413404
# Internal version of walk_tb that yields full code positions including
414405
# end line and column information.
415-
handler_tb = None
416406
while tb is not None:
417-
yield _get_tb_position(tb)
418-
if tb.tb_lineno != tb.tb_frame.f_lineno and _seen:
419-
for exc in reversed(_seen.values()):
420-
if (handler_tb := exc.__traceback__) is not tb:
421-
while handler_tb.tb_frame != tb.tb_frame:
422-
if not (handler_tb := handler_tb.tb_next):
423-
break
424-
else:
425-
break
407+
positions = _get_code_position(tb.tb_frame.f_code, tb.tb_lasti)
408+
# Yield tb_lineno when co_positions does not have a line number to
409+
# maintain behavior with walk_tb.
410+
if positions[0] is None:
411+
yield tb.tb_frame, (tb.tb_lineno, ) + positions[1:]
412+
else:
413+
yield tb.tb_frame, positions
426414
tb = tb.tb_next
427-
if handler_tb:
428-
yield _get_tb_position(handler_tb)
429415

430416

431417
def _get_code_position(code, instruction_index):
@@ -1063,14 +1049,14 @@ def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
10631049
# Handle loops in __cause__ or __context__.
10641050
is_recursive_call = _seen is not None
10651051
if _seen is None:
1066-
_seen = {}
1067-
_seen[id(exc_value)] = exc_value
1052+
_seen = set()
1053+
_seen.add(id(exc_value))
10681054

10691055
self.max_group_width = max_group_width
10701056
self.max_group_depth = max_group_depth
10711057

10721058
self.stack = StackSummary._extract_from_extended_frame_gen(
1073-
_walk_tb_with_full_positions(exc_traceback, _seen),
1059+
_walk_tb_with_full_positions(exc_traceback),
10741060
limit=limit, lookup_lines=lookup_lines,
10751061
capture_locals=capture_locals, cause=exc_value.__cause__,
10761062
context=exc_value.__context__)

0 commit comments

Comments
 (0)