Skip to content

fix: narrow bare except to ImportError in constant module init#69

Open
fix2015 wants to merge 1 commit into
deepseek-ai:mainfrom
fix2015:fix/narrow-bare-except-to-import-error
Open

fix: narrow bare except to ImportError in constant module init#69
fix2015 wants to merge 1 commit into
deepseek-ai:mainfrom
fix2015:fix/narrow-bare-except-to-import-error

Conversation

@fix2015

@fix2015 fix2015 commented Jul 17, 2026

Copy link
Copy Markdown

Summary

The bare except: clause in deepspec/utils/constant/__init__.py catches all exceptions, including KeyboardInterrupt, SystemExit, and SyntaxError. This means that if internal.py contains a real bug (e.g., a syntax error or an unrelated runtime error), it will be silently swallowed and the code will fall back to the public module without any indication of a problem.

This change narrows the exception handler to only catch ImportError and ModuleNotFoundError, which are the expected exceptions when hfai is not installed. Any other exceptions will now properly propagate, making debugging significantly easier.

Changes

  • deepspec/utils/constant/__init__.py: Replace bare except: with except (ImportError, ModuleNotFoundError):

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