Skip to content

Handle None lineno in get_source_context#3925

Merged
sentrivana merged 1 commit into
masterfrom
ivana/source-context-defensive
Jan 14, 2025
Merged

Handle None lineno in get_source_context#3925
sentrivana merged 1 commit into
masterfrom
ivana/source-context-defensive

Conversation

@sentrivana

@sentrivana sentrivana commented Jan 14, 2025

Copy link
Copy Markdown
Contributor

Be more defensive in get_source_context.

The current check makes no sense as we first try to decrement tb_lineno and then check the result against None:

    lineno = tb_lineno - 1
    if lineno is not None and abs_path:

So it looks like this was an oversight/got broken at some point.

Closes #3924

@codecov

codecov Bot commented Jan 14, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.15%. Comparing base (57e9e51) to head (5e2b0f7).
Report is 2 commits behind head on master.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
sentry_sdk/utils.py 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3925      +/-   ##
==========================================
- Coverage   80.16%   80.15%   -0.02%     
==========================================
  Files         139      139              
  Lines       15391    15391              
  Branches     2596     2596              
==========================================
- Hits        12338    12336       -2     
  Misses       2208     2208              
- Partials      845      847       +2     
Files with missing lines Coverage Δ
sentry_sdk/utils.py 83.71% <50.00%> (ø)

... and 2 files with indirect coverage changes

@antonpirker antonpirker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thumbs up!

@sentrivana
sentrivana merged commit 9ff100a into master Jan 14, 2025
@sentrivana
sentrivana deleted the ivana/source-context-defensive branch January 14, 2025 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

2 participants