Skip to content

fix: replace bare except with except KeyError in translator.py#344

Open
koteshyelamati wants to merge 5 commits into
PiotrDabkowski:masterfrom
koteshyelamati:patch-1
Open

fix: replace bare except with except KeyError in translator.py#344
koteshyelamati wants to merge 5 commits into
PiotrDabkowski:masterfrom
koteshyelamati:patch-1

Conversation

@koteshyelamati

Copy link
Copy Markdown

Bare except: clauses catch BaseException, including SystemExit and KeyboardInterrupt.

In translator.py, the bare except: wraps a dict cache lookup — the only possible exception is KeyError (cache miss). Using except KeyError: is the precise fix and makes the intent clearer.

@koteshyelamati

Copy link
Copy Markdown
Author

Extended this PR with fixes for bare except: in 4 constructor files:

  • jsarraybuffer.py, jsfloat32array.py, jsint8array.py, jsuint8array.py: except:except ImportError: around numpy optional import

All four files use the same pattern. The only exception that can occur is ImportError when numpy is absent. This prevents accidentally swallowing SystemExit or KeyboardInterrupt.

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