Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle None lineno in get_source_context #3925

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

sentrivana
Copy link
Contributor

@sentrivana sentrivana commented Jan 14, 2025

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

Copy link

codecov bot commented Jan 14, 2025

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

Copy link
Member

@antonpirker antonpirker left a comment

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
144 of 145 checks passed
@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