Skip to content

Stop swallowing handler errors when errors='raise' - #629

Merged
RazerM merged 1 commit into
mainfrom
fix/handler-raise-policy
Sep 6, 2026
Merged

RazerM merged 1 commit into
mainfrom
fix/handler-raise-policy

Conversation

@RazerM

@RazerM RazerM commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

handle_error kept the flag check and the stacktrace print in one
try/except OSError. That except is there for the print, but it also
caught the exception handle_error re-raises for 'raise'. Most handler
failures are OSError, so most of them raised nothing.

The except predates the flag. In 2010 it wrapped the print alone, and
the raise landed inside it when the flag stack arrived two months
later. CPython scopes the same suppression to the print, see
python/cpython#50221.

@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.30508% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.18%. Comparing base (80c60d7) to head (bc2c064).

Files with missing lines Patch % Lines
tests/test_flags.py 98.07% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #629      +/-   ##
==========================================
+ Coverage   85.04%   85.18%   +0.13%     
==========================================
  Files          45       45              
  Lines        5691     5743      +52     
  Branches      459      460       +1     
==========================================
+ Hits         4840     4892      +52     
  Misses        721      721              
  Partials      130      130              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RazerM
RazerM force-pushed the fix/handler-raise-policy branch 4 times, most recently from 1e56f0e to cd74e51 Compare September 6, 2026 18:27
handle_error kept the flag check and the stacktrace print in one
try/except OSError. That except is there for the print, but it also
caught the exception handle_error re-raises for 'raise'. Most handler
failures are OSError, so most of them raised nothing.

The except predates the flag. In 2010 it wrapped the print alone, and
the raise landed inside it when the flag stack arrived two months
later. CPython scopes the same suppression to the print, see
python/cpython#50221.
@RazerM
RazerM force-pushed the fix/handler-raise-policy branch from cd74e51 to bc2c064 Compare September 6, 2026 19:48
@RazerM
RazerM merged commit 2ae6120 into main Sep 6, 2026
49 checks passed
@RazerM
RazerM deleted the fix/handler-raise-policy branch September 6, 2026 20:12
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.

1 participant