8000 Support exclude in coredumpy.patch_except by fourdim · Pull Request #88 · gaogaotiantian/coredumpy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support exclude in coredumpy.patch_except #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fourdim
Copy link
@fourdim fourdim commented Jun 30, 2025

No description provided.

_original_excepthook = sys.excepthook


def patch_except(path: Optional[Union[str, Callable[[], str]]] = None,
directory: Optional[str] = None):
directory: Optional[str] = None,
exclude: Optional[List[BaseException]] = None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use Sequence rather than List here for type hint. You are converting it to tuple and there's no reason to force it to be a list. Also Exception might be better here because I don't believe SystemExit is caught on sys.excepthook.

An alternative to Sequence is just tuple - immutable is a good thing. You are lazy evaluating this and if it's mutable, it could be changed unexpectedly.

Also, do some sanity check for the argument. We want error out early if what user passes is wrong, not wait until it is evaluated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use Iterable instead and make it immutable internally.

KeyboardInterrupt is a subclass of BaseException but not Exception. I believe that most use case for this exclude will be KeyboardInterrupt, so I preserve it there.

PTAL.

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.

2 participants
0