Skip to content

Fix Custom Excepthook#157

Open
mxkpp wants to merge 5 commits into
ngwpc-candidatefrom
maxkipp-excepthook
Open

Fix Custom Excepthook#157
mxkpp wants to merge 5 commits into
ngwpc-candidatefrom
maxkipp-excepthook

Conversation

@mxkpp
Copy link
Copy Markdown

@mxkpp mxkpp commented May 14, 2026

This fixed 2 issues with the custom excepthook, which is one of the exit-handling methods applied to ensure certain "cleanup" behavior in various exit situations:

  1. There was a typo where sys.excepthook assignment was typed sys.exepthook, so the excepthook was not actually being overridden with a custom method. This typo was masked by how the forcing engine's own err handler was catching exceptions itself and calling sys.exit(1) (triggering the same intended cleanup routine, but for a different exit condition) before the exception bubbled up to the actual Python system excepthook. This typo has been fixed.
  2. The custom excepthook was calling the bare sys.__excepthook__ before calling its custom behavior. The intent here was to perform regular excepthook behavior before the cleanup. However as @idtodd pointed out, this means that if other parts of the program had already reassigned sys.excepthook to a custom callable, then that would not be honored. Instead, this PR changes the forcing engine's custom excepthook to save a copy of sys.excepthook (rather than sys.__excepthook__) to be called later before adding its cleanup steps to the final hook. This essentially extends any existing custom excepthook behavior.
  3. An improvement was added to err_handler.err_out_screen and err_handler.err_out_screen_para to handle cases of a None message being passed as the err_msg argument.

Additions

Removals

Changes

  • Fixed setting of custom excepthook

Testing

  1. I watched behavior in the Python debugger.

Screenshots

Notes

Todos

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Target Environment support

  • Linux

@mxkpp mxkpp requested a review from idtodd May 14, 2026 11:48
@mxkpp
Copy link
Copy Markdown
Author

mxkpp commented May 14, 2026

@idtodd if you could please review this, I would like to push one more improvement to the err_handler.py type-checking before we merge though.

…o function err_handler.err_out_screen or err_handler.err_out_screen_para
@mxkpp
Copy link
Copy Markdown
Author

mxkpp commented May 14, 2026

@idtodd if you could please review this, I would like to push one more improvement to the err_handler.py type-checking before we merge though.

I've added the improved type checking on the error message handling. I believe this is ready to merge afte review.

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