File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -305,7 +305,7 @@ def frame_from_traceback(tb, with_locals=True):
305305
306306 rv = {
307307 "filename" : abs_path and os .path .basename (abs_path ) or None ,
308- "abs_path" : abs_path ,
308+ "abs_path" : os . path . abspath ( abs_path ) ,
309309 "function" : function or "<unknown>" ,
310310 "module" : module ,
311311 "lineno" : tb .tb_lineno ,
Original file line number Diff line number Diff line change 1+ import sys
2+ import os
3+
14from hypothesis import given , assume
25import hypothesis .strategies as st
36
4- from sentry_sdk .utils import safe_repr
7+ from sentry_sdk .utils import safe_repr , exceptions_from_error_tuple
58from sentry_sdk ._compat import text_type
69
710any_string = st .one_of (st .binary (), st .text ())
@@ -23,3 +26,23 @@ def test_safe_repr_never_leaves_escapes_in(x):
2326 r = safe_repr (x )
2427 assert isinstance (r , text_type )
2528 assert u"\\ u" not in r and u"\\ x" not in r
29+
30+
31+ def test_abs_path ():
32+ """Check if abs_path is actually an absolute path. This can happen either
33+ with eval/exec like here, or when the file in the frame is relative to
34+ __main__"""
35+
36+ code = compile ("1/0" , "test.py" , "exec" )
37+ try :
38+ exec (code , {})
39+ except Exception :
40+ exceptions = exceptions_from_error_tuple (sys .exc_info ())
41+
42+ exception , = exceptions
43+ frames = exception ["stacktrace" ]["frames" ]
44+ assert len (frames ) == 2
45+
46+ for frame in frames :
47+ assert os .path .abspath (frame ["abs_path" ]) == frame ["abs_path" ]
48+ assert os .path .basename (frame ["filename" ]) == frame ["filename" ]
You can’t perform that action at this time.
0 commit comments