Skip to content
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

[question] Easiest way (if any) to customize top-level error handling in ptpython repl #544

Open
genovese opened this issue Jul 21, 2023 · 0 comments

Comments

@genovese
Copy link

I'm running a python repl in an educational context, and I would like to catch top level errors of certain types where I can give more clear and complete guidance (and suppress tracebacks where appropriate). I love what ptpython offers, and I would like to use it here. Is there a relatively simple way to adapt ptpython to customize error handling at the top level of the interactive shell?

If there is no direct way, it looks like modifying/wrapping PythonRepl._handle_exception could work, but perhaps there's a better or simpler way? Or perhaps that won't work at all for some reason? My first thought was to allow an optional kw argument to the PythonRepl constructor that takes a custom error handler and that this handler is tried first, then the current _handle_exception if the former is missing or passes. Sound plausible, or crazy?

Thanks for your help!

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

No branches or pull requests

1 participant