Skip to content

fix: replace bare except clauses with specific exception types#80

Open
haosenwang1018 wants to merge 1 commit intoHKUDS:mainfrom
haosenwang1018:fix/browser-env-bare-excepts
Open

fix: replace bare except clauses with specific exception types#80
haosenwang1018 wants to merge 1 commit intoHKUDS:mainfrom
haosenwang1018:fix/browser-env-bare-excepts

Conversation

@haosenwang1018
Copy link

Problem

Several files use bare except: which catches BaseException including SystemExit and KeyboardInterrupt. This can mask critical errors and make debugging harder (PEP 8 E722).

Changes

File Exception Type Rationale
browser_env.py (2 sites) Exception Playwright timeout/navigation errors
local_env.py (subprocess.SubprocessError, OSError) Conda path discovery failures
registry.py (TypeError, OSError) inspect.getfile() on builtins/C extensions

Why specific types matter

Bare except: silently swallows KeyboardInterrupt (Ctrl+C) and SystemExit, preventing clean shutdown. Using specific exception types preserves the intended error-swallowing behavior while allowing critical signals to propagate.

Bare 'except:' catches BaseException including SystemExit and
KeyboardInterrupt, which can mask critical errors and make debugging
harder. Replace with appropriate specific exception types:

- browser_env.py: except Exception (Playwright timeout/navigation)
- local_env.py: except (subprocess.SubprocessError, OSError)
- registry.py: except (TypeError, OSError) for inspect.getfile()
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