This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dwr2
Recipients dwr2, eric.araujo, tarek
Date 2010-12-07.03:35:15
SpamBayes Score 9.431367e-11
Marked as misclassified No
Message-id <1291692920.89.0.675754694355.issue10642@psf.upfronthosting.co.za>
In-reply-to
Content
Python 2.7 programs crash on startup due to a defective third-party package installed in site-packages.

starting python 2.7 yields the following error message:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site.py", line 554, in <module>
    main()
  File "/usr/lib64/python2.7/site.py", line 537, in main
    known_paths = addsitepackages(known_paths)
  File "/usr/lib64/python2.7/site.py", line 316, in addsitepackages
    addsitedir(sitedir, known_paths)
  File "/usr/lib64/python2.7/site.py", line 192, in addsitedir
    addpackage(sitedir, name, known_paths)
  File "/usr/lib64/python2.7/site.py", line 162, in addpackage
    exec line
  File "<string>", line 1, in <module>
KeyError: 'zope'

A similar message appears when starting python2.7 interactively, but it then proceeds to the prompt (doesn't crash).

In the file .../python2.7/site.py, at about line 162, in the function "addpackage", you have an
unprotected "exec" line:
    if line.startswith(("import ", "import\t")):
        exec line

If the execution of the line fails, python generates an uncaught exception.
This places python at the mercy of bugs in third-party software.

The "exec" line should be bracketed by "try/except" to catch such errors:
    if line.startswith(("import ", "import\t")):
        try:
            exec line
        except:
            pass
        continue

Note 1: I am not sure whether this is a Distutils bug or Distutils2 bug (or even something else like "Extension Modules"), so I'm filing it under Distutils2. If this is incorrect, please forward to the proper place. Thanks.

Note 2: Here is where I initially reported this problem: http://bugs.gentoo.org/show_bug.cgi?id=347565
History
Date User Action Args
2010-12-07 03:35:20dwr2setrecipients: + dwr2, tarek, eric.araujo
2010-12-07 03:35:20dwr2setmessageid: <1291692920.89.0.675754694355.issue10642@psf.upfronthosting.co.za>
2010-12-07 03:35:16dwr2linkissue10642 messages
2010-12-07 03:35:15dwr2create