classification
Title: addpackage in site.py fails hard on badly formed .pth files
Type: behavior Stage:
Components: Versions:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: jwheare (1)
Priority: Keywords

Created on 2009-02-14 12:36 by jwheare, last changed 2009-02-14 12:41 by jwheare.

Messages (2)
msg82032 - (view) Author: James Wheare (jwheare) Date: 2009-02-14 12:36
As described here: http://james.wheare.org/notes/2009/02/import-site-
failed-use-v-for-traceback.php

The addpackage function will result in a TypeError being raised from os.path.exists(dir) -> from os.stat(path) if the contents of an 
inspected .pth file contain binary data.

This can happen in OS X network environments where ._ AppleDouble files 
are created to store resource forks and file metadata.

As this function is run whenever the interpreter is initialised, Python 
should be robust enough to ignore invalid data in these files, either by 
catching the TypeError in os.path.exists, or by detecting them at a 
higher level, but should be careful of false positives.

Another alternative is to raise a different exception and use it to 
display more helpful debugging info for those not familiar with pdb.
msg82034 - (view) Author: James Wheare (jwheare) Date: 2009-02-14 12:40
To clarify, the exception doesn't interrupt the interpreter, but the 
only indication of a problem is the following message:

'import site' failed; use -v for traceback

And you're then unable to import modules from site-packages.

Also, here's a clickable link to the blog post with more details:

http://tinyurl.com/dnlepc

(rather aggressive line length enforcement going on here...)
History
Date User Action Args
2009-02-14 12:41:00jwhearesetmessages: + msg82034
2009-02-14 12:36:02jwhearecreate