Skip to content

fix(serialize): Do not attach stacktrace with empty frames #740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,18 +447,6 @@ def serialize_frame(frame, tb_lineno=None, with_locals=True):
return rv


def stacktrace_from_traceback(tb=None, with_locals=True):
# type: (Optional[TracebackType], bool) -> Dict[str, List[Dict[str, Any]]]
return {
"frames": [
serialize_frame(
tb.tb_frame, tb_lineno=tb.tb_lineno, with_locals=with_locals
)
for tb in iter_stacks(tb)
]
}


def current_stacktrace(with_locals=True):
# type: (bool) -> Any
__tracebackhide__ = True
Expand Down Expand Up @@ -504,14 +492,23 @@ def single_exception_from_error_tuple(
else:
with_locals = client_options["with_locals"]

return {
frames = [
serialize_frame(tb.tb_frame, tb_lineno=tb.tb_lineno, with_locals=with_locals)
for tb in iter_stacks(tb)
]

rv = {
"module": get_type_module(exc_type),
"type": get_type_name(exc_type),
"value": safe_str(exc_value),
"mechanism": mechanism,
"stacktrace": stacktrace_from_traceback(tb, with_locals),
}

if frames:
rv["stacktrace"] = {"frames": frames}

return rv


HAS_CHAINED_EXCEPTIONS = hasattr(Exception, "__suppress_context__")

Expand Down