-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Click raises RuntimeError even when exit code = 0, hence gives error in ipython #2249
Comments
Click makes command line programs. Programs exit after they are finished. Use |
ok, but is it normal for a program to exit by raising an exception even when nothing went wrong? Is there no other way for click to exit in the case of Thanks for the tip about |
10 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When click exits, it raises a RuntimeError even when everything worked ok. Hence, if I wrap a call to a click command inside a
try/except
, this will be picked up as an exception even though nothing went wrong.This creates a problem with ipython, which catches all exceptions and does some custom handling of them. What happens appears to be: ipython executes the code, click raises the
RuntimeError
, ipython catches it but because there's no actual error message or traceback, ipython seems to get confused and generates even more exceptions.Is there a reason why click raises an exception even when the program ran ok and
code == 0
? I changed the click behaviour very slightly to no longer do so and it fixes this completely, but I'm guessing there's a reason click doesn't do this already?Steps to reproduce
ipython
from hello import hello; hello()
hello(["--count", 3])
but will afterwards produce the following exception (see full traceback):Note: that
ipython -m hello
works ok, as does the above flow when usingpython
. It's only when running an interactive ipython session that click's RuntimeError is problematic.What should happen
No traceback from ipython.
Environment
The text was updated successfully, but these errors were encountered: