Python process doesn't get terminated using Ctrl-C if site.py is being imported

Joonas Paalasmaa joonas.paalasmaa at iki.fi
Wed Feb 26 12:59:36 EST 2003


Hello,

When a python script is ran, python imports site.py before running the
script. If Ctrl-C is hit during the import, the process displays an error,
but the process doesn't get terminated. This can be a bit confusing, since
users usually expect that a program is terminated if Ctrl-C is hit. The
problem can be avoided using "python -S script.py", and importing site.py
in script.py before any other modules. Does this solution guarantee same
behaviour as normal execution of scripts?

- Joonas

[~/reportbug] cat test.py
print "foo"
[~/reportbug] python test.py
'import site' failed; use -v for traceback
foo
[~/reportbug]






More information about the Python-list mailing list