On 13/05/2024 21:48, Collin Funk wrote:
Hi Paul,
On 5/13/24 9:39 AM, Paul Eggert wrote:
I realized that I invoked ' ./gnulib-tool --create-testdir --dir foo stdbit'
with the wrong options so I interrupted it with control-C. It then gave me the
following long traceback, which is not useful. I suggest shutting off the
Python traceback info after control-C unless perhaps some new debugging option
is used.
Thanks for the suggestion. I agree, but I need to find the correct way
to do that. IIRC some Python packages I have used do it properly but
others just do an ugly traceback.
I think that control-C raises a KeyboardInterrupt. The Python
documentation notes some special considerations that need to be made
there [1].
Collin
[1] https://docs.python.org/3/library/exceptions.html#KeyboardInterrupt
I've an 18 year old script template here that silences Ctrl-C spew:
https://www.pixelbeat.org/talks/python/cli_skel.py
You can see a more modern usage of that in crudini at:
https://github.com/pixelb/crudini/blob/cbb3b85e/crudini.py#L1134
Note that also handles a closed stdin (and stdout elsewhere in that util).
cheers,
Pádraig