Skip to content

Commit 68af9b3

Browse files
committed
fix(debug): guard stack extraction
1 parent 825e943 commit 68af9b3

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

uvloop/cbhandles.pyx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -423,19 +423,14 @@ cdef extract_stack():
423423
if f is None:
424424
return
425425

426+
if getattr(f, "f_lineno", None) is None or getattr(f, "f_code", None) is None:
427+
return None
426428
try:
427-
frames = []
428-
while f is not None:
429-
lineno = getattr(f, "f_lineno", None)
430-
if lineno is None:
431-
break
432-
if getattr(f, "f_code", None) is None:
433-
break
434-
frames.append((f, lineno))
435-
f = getattr(f, "f_back", None)
436-
stack = tb_StackSummary.extract(frames,
429+
stack = tb_StackSummary.extract(tb_walk_stack(f),
437430
limit=DEBUG_STACK_DEPTH,
438431
lookup_lines=False)
432+
except (AttributeError, TypeError):
433+
return None
439434
finally:
440435
f = None
441436

0 commit comments

Comments
 (0)