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):
305
305
306
306
rv = {
307
307
"filename" : abs_path and os .path .basename (abs_path ) or None ,
308
- "abs_path" : abs_path ,
308
+ "abs_path" : os . path . abspath ( abs_path ) ,
309
309
"function" : function or "<unknown>" ,
310
310
"module" : module ,
311
311
"lineno" : tb .tb_lineno ,
Original file line number Diff line number Diff line change
1
+ import sys
2
+ import os
3
+
1
4
from hypothesis import given , assume
2
5
import hypothesis .strategies as st
3
6
4
- from sentry_sdk .utils import safe_repr
7
+ from sentry_sdk .utils import safe_repr , exceptions_from_error_tuple
5
8
from sentry_sdk ._compat import text_type
6
9
7
10
any_string = st .one_of (st .binary (), st .text ())
@@ -23,3 +26,23 @@ def test_safe_repr_never_leaves_escapes_in(x):
23
26
r = safe_repr (x )
24
27
assert isinstance (r , text_type )
25
28
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