R. David Murray <rdmur...@bitdance.com> added the comment: Yes, I think it is a good idea for site.py to issue error messages and continue on when it is processing files that don't come from the python distribution itself (such as pth files). However, I think just printing the error message is not going to provide enough info. For example the error in this issue would produce something like:
TypeError: embedded NUL character Which wouldn't be much of a clue as to what went wrong. Likewise the case of a pth file containing a like this: import foo)bar This would result in an error message like this: SyntaxError: invalid syntax This seems fine at first glance, but what if the pth file is: import foo and foo.py is: foo)bar We get the *same* error message, but the pth file itself is syntactically correct. So, I think it is better to print the traceback, even if it results in extra info (lines from the addpackage routine itself). Attached is a patch that takes this approach. I locate this code in addpackage itself so that I can get the line number from the pth file for the error message, further localizing it. And I wrap all of the code that I think could throw errors due to bad pth files, but only that code. Note that both of these patches also address issue 10642, so I'm going to make this a superseder for that issue. If you like this approach, Georg, then we just need unit tests :) ---------- stage: -> patch review Added file: http://bugs.python.org/file20159/site_pth_exceptions.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5258> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com