[issue3137] Python doesn't handle SIGINT well if it arrives during interpreter startup

STINNER Victor report at bugs.python.org
Mon Mar 8 01:10:20 CET 2010


STINNER Victor <victor.stinner at haypocalc.com> added the comment:

I think initsite() should be atomic: if any kind of error occurs, Python should print it and exit directly (exit code 1 to notice the error). If initsite() fails, Python is not complelty initialized.

site is responsible to initialiaze a lot of things:

 - Set all module' __file__ attribute to an absolute path
 - Remove duplicate entries from sys.path along with making them absolute
 - Add a per user site-package to sys.path
 - Add site-packages (and possibly site-python) to sys.path
 - Define new built-ins 'quit' and 'exit'.
 - Set 'copyright' and 'credits' in __builtin__"
 - Create builtin help() function
 - On Windows, some default encodings are not provided by Python, while they are always available as "mbcs" in each locale. Make them usable by aliasing to "mbcs" in such a case.
 - import sitecustomize
 - import usercustomize
 - del sys.setdefaultencoding
 - etc.

Be able to ignore the site initializations might be a security vulnerability.

Attached patch consider any exception as fatal: display the error and exit. I moved the call to _PyGILState_Init() before initsite() to avoid a crash in Py_Finalize() => see #8063.

----------
keywords: +patch
nosy: +haypo
Added file: http://bugs.python.org/file16488/initsite.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3137>
_______________________________________


More information about the Python-bugs-list mailing list