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 r.david.murray
Recipients georg.brandl, jwheare, r.david.murray
Date 2010-12-25.03:54:25
SpamBayes Score 2.220446e-16
Marked as misclassified No
Message-id <1293249268.21.0.360400601731.issue5258@psf.upfronthosting.co.za>
In-reply-to
Content
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 :)
History
Date User Action Args
2010-12-25 03:54:28r.david.murraysetrecipients: + r.david.murray, georg.brandl, jwheare
2010-12-25 03:54:28r.david.murraysetmessageid: <1293249268.21.0.360400601731.issue5258@psf.upfronthosting.co.za>
2010-12-25 03:54:25r.david.murraylinkissue5258 messages
2010-12-25 03:54:25r.david.murraycreate