Skip to content

Commit ccd083f

Browse files
masahiro331mitsuhiko
authored andcommitted
bugfix: refacter utils get_source_context (#30)
1 parent d497b6e commit ccd083f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sentry_sdk/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def get_lines_from_file(filename, lineno, loader=None, module=None):
202202
return [], None, []
203203

204204

205-
def get_source_context(frame):
205+
def get_source_context(frame, tb_lineno):
206206
try:
207207
abs_path = frame.f_code.co_filename
208208
except Exception:
@@ -215,7 +215,7 @@ def get_source_context(frame):
215215
loader = frame.f_globals["__loader__"]
216216
except Exception:
217217
loader = None
218-
lineno = frame.f_lineno - 1
218+
lineno = tb_lineno - 1
219219
if lineno is not None and abs_path:
220220
return get_lines_from_file(abs_path, lineno, loader, module)
221221
return [], None, []
@@ -287,7 +287,7 @@ def frame_from_traceback(tb, with_locals=True):
287287
except Exception:
288288
module = None
289289

290-
pre_context, context_line, post_context = get_source_context(frame)
290+
pre_context, context_line, post_context = get_source_context(frame, tb.tb_lineno)
291291

292292
rv = {
293293
"filename": abs_path and os.path.basename(abs_path) or None,

0 commit comments

Comments
 (0)