Package: python2.6 Version: 2.6.6-8+b1 The Python interpreter arranges (during its startup) to trap SIGINT and turn it into a KeyboardInterrupt exception. If this happens before the execution of the part of the script (if any) which takes countermeasures against this feature, the result is that the interpreter prints the stack traceback to stderr and calls _exit(1) (so that WIFEXITED(status) && WEXITSTATUS(status)==1).
This is a problem because it makes it impossible to write in Python programs which behave like normal Unix programs - ie, which if they receive a SIGINT always die with WIFSIGANLED(status) && WTERMSIG(status)==SIGINT. For example, the "command-not-found" helper program is written in Python and sometimes prints spurious stack traces. As another example, any Python program which is expected to implement the interface of (say) "diff" is buggy, because it may exit status 1 ("comparison successful; differences found") when it should have died with SIGINT ("comparison not completed due to interrupt signal"); this could in principle cause data loss in some applications. It is possible to reduce but not eliminate the time window during which the bug will occur, by using Python's signal handling machinery to put SIGINT back to SIG_DFL - ideally near the top of the script. However, what is really needed is a way to fix the problem entirely. Therefore we need a way to tell the Python interpreter not to trap SIGINT. Not trapping SIGINT is better for programs because if they want to trap it they can always do that themselves at any suitable time during startup. (Any program which relies on trapping SIGINT at _all_ times even before it gets control is buggy, of course, since SIGINT may occur while eg the runtime linker is running.) However, this would be an incompatible change. There therefore needs to be a way for a script to declare to Python that normal SIGINT behaviour is what it wants. I suggest that this should be a new command-line option. The semantics of the option should simply be to disable the setup of the default SIGINT trap. This option can then be added to the #! line of all Python scripts. (Or, at least, all Python scripts which might be invoked in circumstances where it matters.) I haven't done a comprehensive survey of affected Python scripts in Debian, but almost anything in /usr/bin starting #!/usr/bin/python* is probably affected. Since I actually triggered this bug with command-not-found, I will submit a bug about that specific instance and set this bug to block it. Please do not simply close this bug against Python unless either: (a) you persuade the authors of command-not-found that the behaviour exhibited by command-not-found (ie sometimes producing an asynchronous stack backtrace to the user's stderr when they hit ^C) is not a bug; or (b) you explain some other reasonable way to fix the bug in command-not-found. Naturally this bug is in all versions of Python in Debian, ever. Ian. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org