You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like the output redirection for CliRunner doesn't play nicely with Python's faulthandler library, as it terminates prematurely with the following backtrace (slightly modified to hide local filesystem details):
Traceback (most recent call last):
File "$CONDA_PREFIX/lib/python3.11/site-packages/click/testing.py", line 408, in invoke
return_value = cli.main(args=args or (), prog_name=prog_name, **extra)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$CONDA_PREFIX/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "$CONDA_PREFIX/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "$CONDA_PREFIX/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "./test_click.py", line 12, in main
faulthandler.enable()
io.UnsupportedOperation: fileno
Code for test_click.py that replicates the problem:
importclickfromclick.testingimportCliRunnerimportfaulthandlerimporttraceback@click.command()@click.option('--flag', type=bool, default=True)defmain(flag):
print("Executing main function...")
ifflag:
print("Registering faulthandler")
faulthandler.enable()
print("Finished executing main function.")
if__name__=='__main__':
flag_value=Truerunner=CliRunner()
result=runner.invoke(main, ["--flag", flag_value])
print("Exit code = %d; contents of stdout:\n%s"% (result.exit_code, result.stdout))
ifresult.exit_code!=0:
traceback.print_exception(result.exc_info[1])
The code was then executed by running python test_click.py
I assume the problem is that the CliRunner redirected stderr doesn't implement some details that are required by the faulthandler signal handler registration. Ideally, it should just work; or at least, it should avoid crashing and just do nothing (and perhaps be documented somewhere).
Environment:
Python version: 3.11.10
Click version: 8.1.7
The text was updated successfully, but these errors were encountered:
It looks like the output redirection for
CliRunner
doesn't play nicely with Python'sfaulthandler
library, as it terminates prematurely with the following backtrace (slightly modified to hide local filesystem details):Code for
test_click.py
that replicates the problem:The code was then executed by running
python test_click.py
I assume the problem is that the
CliRunner
redirected stderr doesn't implement some details that are required by thefaulthandler
signal handler registration. Ideally, it should just work; or at least, it should avoid crashing and just do nothing (and perhaps be documented somewhere).Environment:
The text was updated successfully, but these errors were encountered: