@@ -738,7 +738,7 @@ def single_exception_from_error_tuple(
738738 exception_id = None , # type: Optional[int]
739739 parent_id = None , # type: Optional[int]
740740 source = None , # type: Optional[str]
741- full_stack = None ,
741+ full_stack = None ,
742742):
743743 # type: (...) -> Dict[str, Any]
744744 """
@@ -813,6 +813,50 @@ def single_exception_from_error_tuple(
813813 # elements of frames list look like this:
814814 # {'filename': 'main.py', 'abs_path': '/Users/antonpirker/code/testing-sentry/test-plain-python-missing-stack-frames/main.py', 'function': 'foo', 'module': '__main__', 'lineno': 19, 'pre_context': [' foo()', '', '', 'def foo():', ' try:'], 'context_line': ' bar()', 'post_context': [' except Exception as e:', ' capture_exception(e)', '', '', 'def bar():'], 'vars': {'e': "Exception('1 some exception')"}}
815815 # elements of full_stack are instances of type FrameSummary
816+
817+ full_stack .reverse ()
818+ frames .reverse ()
819+
820+ for stackframe in full_stack :
821+ stackframe_id = {
822+ "filename" : stackframe .filename ,
823+ "line" : stackframe .line ,
824+ "lineno" : stackframe .lineno ,
825+ "name" : stackframe .name ,
826+ }
827+
828+ found = False
829+ for frame in frames :
830+ frame_id = {
831+ "filename" : frame ["abs_path" ],
832+ "line" : frame ["context_line" ],
833+ "lineno" : frame ["lineno" ],
834+ "name" : frame ["function" ],
835+ }
836+
837+ if stackframe_id == frame_id :
838+ found = True
839+ break
840+
841+ if not found :
842+ frames .append (
843+ {
844+ "filename" : os .path .basename (stackframe .filename ),
845+ "abs_path" : stackframe .filename ,
846+ "function" : stackframe .name ,
847+ "module" : None ,
848+ "lineno" : stackframe .lineno ,
849+ "pre_context" : [],
850+ "context_line" : stackframe .line ,
851+ "post_context" : [],
852+ "vars" : {},
853+ }
854+ )
855+
856+ frames .reverse ()
857+ from pprint import pprint
858+
859+ pprint (frames )
816860 exception_value ["stacktrace" ] = {"frames" : frames }
817861
818862 return exception_value
@@ -986,10 +1030,10 @@ def exceptions_from_error_tuple(
9861030 exceptions .append (
9871031 single_exception_from_error_tuple (
9881032 exc_type = exc_type ,
989- exc_value = exc_value ,
990- tb = tb ,
991- client_options = client_options ,
992- mechanism = mechanism ,
1033+ exc_value = exc_value ,
1034+ tb = tb ,
1035+ client_options = client_options ,
1036+ mechanism = mechanism ,
9931037 full_stack = full_stack ,
9941038 )
9951039 )
0 commit comments