[issue14228] It is impossible to catch sigint on startup in python code

2013-12-21 Thread STINNER Victor
STINNER Victor added the comment: Sorry, but I don't understand this issue. Well, I understood the issue as When I press CTRL+c to interrupt Python, Python does exit. What's wrong with that? Why do you send CTRL+c if you don't want Python to exit? Using custom signal handler (SIG_IGN), it

[issue14228] It is impossible to catch sigint on startup in python code

2013-12-21 Thread telmich
telmich added the comment: Victor, the problem is *not* that python exits. This is fine and virtually every other unix program behaves like that. The problem is that python throws an ugly-to-read and completly senseless backtrace to the novice (end!) user by default. Backtraces are great for

[issue14228] It is impossible to catch sigint on startup in python code

2013-12-17 Thread Yongzhi Pan
Changes by Yongzhi Pan fossi...@users.sourceforge.net: -- nosy: +fossilet ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___

[issue14228] It is impossible to catch sigint on startup in python code

2013-12-14 Thread Jurko Gospodnetić
Changes by Jurko Gospodnetić jurko.gospodne...@gmail.com: -- components: +email -Interpreter Core nosy: +Jurko.Gospodnetić, barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___

[issue14228] It is impossible to catch sigint on startup in python code

2013-12-14 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- components: +Interpreter Core -email ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___

[issue14228] It is impossible to catch sigint on startup in python code

2013-12-14 Thread Jurko Gospodnetić
Jurko Gospodnetić added the comment: This issue is related to issue #19983 on Windows. Also, I do not think the suggested -z option implementation should be accepted 'as is'. On Unix it would make Ctrl-C silently terminate the process if it occurs before default Python signal handling is

[issue14228] It is impossible to catch sigint on startup in python code

2012-11-12 Thread Eric Snow
Changes by Eric Snow ericsnowcurren...@gmail.com: -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list

[issue14228] It is impossible to catch sigint on startup in python code

2012-11-08 Thread telmich
telmich added the comment: I created two diffs to solve the problem: a) a static late init of the signal handler b) configurable late init (using python -z) Both apply against latest mercurial code: [15:20] brief:cpython% ./python -V Python 3.4.0a0 [15:20] brief:cpython% ./python -h | grep --

[issue14228] It is impossible to catch sigint on startup in python code

2012-11-08 Thread telmich
telmich added the comment: + parameter -z based change of behaviour -- Added file: http://bugs.python.org/file27925/init_sigs_after_site_parameter_z.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228

[issue14228] It is impossible to catch sigint on startup in python code

2012-11-08 Thread telmich
telmich added the comment: And sorry for the long delay... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list mailing

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-26 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Why an environment variable instead of a command line switch (as suggested by Ian Jackson)? Shouldn't a script be able to decide for itself how it handles signals? Because the available space for command line switches is rather limited, and

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-26 Thread poq
poq p...@gmx.com added the comment: Because the available space for command line switches is rather limited Limited by what? MYENVVAR=foo python ... That does not work with hashbangs (and env is kludgey). -- ___ Python tracker

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-26 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Limited by what? The alphabet. I suppose we could use a -- option, but somebody would have to add support for those. -- ___ Python tracker rep...@bugs.python.org

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-25 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: @telmich: I think you will have more success at getting what you want if you work with us rather than being confrontational. Respect that we have reasons for doing things a certain way (and not because we are stupid), and we will

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-23 Thread Charles-François Natali
Charles-François Natali neolo...@free.fr added the comment: In any case, I'd appreciate, if cpython would be changed to something more sane/less verbose by default. By default, certainly not. -- ___ Python tracker rep...@bugs.python.org

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-23 Thread telmich
telmich nico-bugs.python@schottelius.org added the comment: Hello François, I'm confused about your statement: You prefer to throw random and useless error messages to users who are using python instead of doing a clean shutdown like every other application by default? Don't be offended,

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-23 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Don't be offended, but this looks like a software coded by a 12 years old, who is proud about it and does not accept an error being an error and insists on doing it right, although it's a common understanding that throwing errors in non error

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-23 Thread telmich
telmich nico-bugs.python@schottelius.org added the comment: Antoine, let me explain again: I do not say, python should not print uncaught exceptions. My point here is that an exception is thrown, which is not catchable at all and this results in random and misleading errors. I really

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-23 Thread poq
poq p...@gmx.com added the comment: No, the point is that the exception may be caused by a real bug and having the traceback is tremendously useful to debug such situations. [...] KeyboardInterrupt is not different in this regard from, say, ZeroDivisionError. KeyboardInterrupt *is*

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-22 Thread telmich
telmich nico-bugs.python@schottelius.org added the comment: It seems not even using -S fixes the problem: [16:25] brief:python-traceback-test% head -n 2 caller.py #!/usr/bin/python3 -S [16:25] brief:python-traceback-test% ./caller.py Indirect child being called Indirect child being

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-22 Thread telmich
telmich nico-bugs.python@schottelius.org added the comment: I think setting up SIGINT after importing site is a good solution: It will kill the program as expected and as soon as the user takes over control, she can decide what todo. In which stage/part is the python interpreter when I

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-22 Thread poq
poq p...@gmx.com added the comment: It seems not even using -S fixes the problem That's because you try to use re and os in your except block, and the KeyboardInterrupt is raised before they are imported. -- nosy: +poq ___ Python tracker

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-22 Thread telmich
telmich nico-bugs.python@schottelius.org added the comment: Oh yes, you are right. Sorry for the confusion. When modifying caller.py to only print(), everything works. But then I've a different problem: If I want to exit(1), in case I get a SIGINT, I'd like to try to import sys. But trying

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-20 Thread Charles-François Natali
Charles-François Natali neolo...@free.fr added the comment: for everybody who is not *programming* python (imagine there is a *real* user) the tracebacks are useless. Even worse, because the error messages are *changing*, because of different library parts not catching the exception. Well,

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-20 Thread Charles-François Natali
Charles-François Natali neolo...@free.fr added the comment: Or we could change Py_InitializeEx() to setup the signal handlers after having imported the site module: Note that I don't really like this solution, because it's better to setup handlers for fatal signals (SIGPIPE, SIGXF...) before

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-20 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Or we could change Py_InitializeEx() to setup the signal handlers after having imported the site module: Note that I don't really like this solution, because it's better to setup handlers for fatal signals (SIGPIPE, SIGXF...) before

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-19 Thread Charles-François Natali
Charles-François Natali neolo...@free.fr added the comment: I must be missing something, but I fail to see the problem here. Basically, when SIGINT is received before the user code is run, it's caught by the default handler which prints a traceback and exits. What's wrong with that? Not

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-19 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: If one could distinguish that python had ended because of a sigint from the error code, then it would be possible for the caller to throw away stderr in that case. I agree with the OP that that having to deal with the traceback when

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-19 Thread telmich
telmich nico-bugs.python@schottelius.org added the comment: Dear Charles-François, for everybody who is not *programming* python (imagine there is a *real* user) the tracebacks are useless. Even worse, because the error messages are *changing*, because of different library parts not

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-11 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14228 ___ ___ Python-bugs-list

[issue14228] It is impossible to catch sigint on startup in python code

2012-03-09 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: Ok, I see. Would an option to disable the default SIGINT handlers (and let the OS kill the process) be an acceptable solution to your use case? Keep in mind that letting the OS kill the process will bypass any destructors at the Python level,