Skip to content

fix: replace bare except with except Exception in websocket_server.py - #218

Open
KeloYuan wants to merge 1 commit into
reloadware:mainfrom
KeloYuan:fix/bare-except-improvements
Open

fix: replace bare except with except Exception in websocket_server.py#218
KeloYuan wants to merge 1 commit into
reloadware:mainfrom
KeloYuan:fix/bare-except-improvements

Conversation

@KeloYuan

@KeloYuan KeloYuan commented May 8, 2026

Copy link
Copy Markdown

Summary

Replaces bare except: with except Exception: in src/websocket_server.py (line 219).

Context

The bare except wraps SSL socket creation. When key/cert files are not found, the bare except silently swallows all exceptions including SystemExit and KeyboardInterrupt.

Why

except Exception: preserves the same error handling behavior while respecting system-level exceptions like KeyboardInterrupt (Ctrl+C) and SystemExit.

The bare except: catches SystemExit and KeyboardInterrupt, which can
mask critical signals during SSL handshake failures.
Copilot AI review requested due to automatic review settings May 8, 2026 13:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves exception handling in the WebSocket server’s TLS wrapping path by replacing a bare except: with except Exception: so that system-level exceptions (e.g., KeyboardInterrupt, SystemExit) are not swallowed during SSL socket setup.

Changes:

  • Replaced a bare except: with except Exception: around ssl.wrap_socket(...) in WebSocketHandler.__init__.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/websocket_server.py
Comment on lines +219 to 220
except Exception: # Not sure which exception it throws if the key/cert isn't found
pass
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.

2 participants