Skip to content

Conversation

@alexrudd2
Copy link

@alexrudd2 alexrudd2 commented Apr 1, 2025

Per the exception heirarchy, there are 3 Exceptions derived from Exception and not BaseException.

  • KeyboardInterrupt
  • SystemExit
  • GeneratorExit

KeyboardInterrupt and SystemExit are typically not caught, as Python is closing anyways. I believe catching them interferes with e.g. CTRL+C.

GeneratorExit does not seem relevant here. Even if it were, it must be re-raised or RuntimeError: generator ignored GeneratorExit will occur.

I therefore propose changing all usages of except BaseException to except Exception.

This resolves a single error with pyright or mypy. However, it does technically represent a change from pyserial.

@alexrudd2 alexrudd2 mentioned this pull request Apr 1, 2025
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