Skip to content

Narrow optional import exception handling in pyisolate.__init__#197

Merged
seanwevans merged 1 commit intomainfrom
codex/update-import-error-handling-in-pyisolate
Apr 21, 2026
Merged

Narrow optional import exception handling in pyisolate.__init__#197
seanwevans merged 1 commit intomainfrom
codex/update-import-error-handling-in-pyisolate

Conversation

@seanwevans
Copy link
Copy Markdown
Owner

Motivation

  • Avoid silently swallowing unrelated import-time errors in optional modules so developer-visible bugs surface during import.
  • Continue to treat the checkpoint/migration features as optional when the cryptography dependency is absent.
  • Preserve the existing public API and error semantics for users when optional crypto support is unavailable.

Description

  • Replace broad except Exception around from .checkpoint import checkpoint, restore and from .migration import migrate with except (ModuleNotFoundError, ImportError) and inspect the exception before deciding to swallow it.
  • Re-raise ModuleNotFoundError/ImportError instances that do not indicate the cryptography dependency is missing so unexpected import-time failures propagate.
  • Preserve the fallback callables checkpoint, restore, and migrate that raise ModuleNotFoundError("cryptography is required ...") to keep the same API shape and messages.
  • Add brief inline comments explaining that only dependency-related import failures are intentionally trapped.

Testing

  • Ran python -m compileall pyisolate/__init__.py which completed successfully.

Codex Task

@seanwevans seanwevans merged commit 626b149 into main Apr 21, 2026
9 of 19 checks passed
@seanwevans seanwevans deleted the codex/update-import-error-handling-in-pyisolate branch April 21, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant