Skip to content

Commit b92b2b0

Browse files
authored
fix(serialize): Do not attach stacktrace with empty frames (getsentry#740)
* fix(serialize): Do not attach stacktrace with empty frames * do not attach None
1 parent 4a28a3b commit b92b2b0

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

sentry_sdk/utils.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -458,18 +458,6 @@ def serialize_frame(frame, tb_lineno=None, with_locals=True):
458458
return rv
459459

460460

461-
def stacktrace_from_traceback(tb=None, with_locals=True):
462-
# type: (Optional[TracebackType], bool) -> Dict[str, List[Dict[str, Any]]]
463-
return {
464-
"frames": [
465-
serialize_frame(
466-
tb.tb_frame, tb_lineno=tb.tb_lineno, with_locals=with_locals
467-
)
468-
for tb in iter_stacks(tb)
469-
]
470-
}
471-
472-
473461
def current_stacktrace(with_locals=True):
474462
# type: (bool) -> Any
475463
__tracebackhide__ = True
@@ -515,14 +503,23 @@ def single_exception_from_error_tuple(
515503
else:
516504
with_locals = client_options["with_locals"]
517505

518-
return {
506+
frames = [
507+
serialize_frame(tb.tb_frame, tb_lineno=tb.tb_lineno, with_locals=with_locals)
508+
for tb in iter_stacks(tb)
509+
]
510+
511+
rv = {
519512
"module": get_type_module(exc_type),
520513
"type": get_type_name(exc_type),
521514
"value": safe_str(exc_value),
522515
"mechanism": mechanism,
523-
"stacktrace": stacktrace_from_traceback(tb, with_locals),
524516
}
525517

518+
if frames:
519+
rv["stacktrace"] = {"frames": frames}
520+
521+
return rv
522+
526523

527524
HAS_CHAINED_EXCEPTIONS = hasattr(Exception, "__suppress_context__")
528525

0 commit comments

Comments
 (0)