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 docs@python, ezio.melotti, marco.buttu, pconnell, r.david.murray, vajrasky
Date 2013-10-09.20:04:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1381349050.11.0.252817019187.issue16355@psf.upfronthosting.co.za>
In-reply-to
Content
Looking at the source, the suppression of errors is clearly intentional.  Looking at the change that added the TypeError check, we see this from Jeremy Hilton in March 2002 (9c2ca37bdeec):

    It appears that getcomments() can get called for classes defined in
    C.  Since these don't have source code, it can't do anything useful.
    A function buried many levels deep was raising a TypeError that was
    not caught.

    Who knows why this broke...

Which implies that getcomments was being called from somewhere in Python itself...at least back then.

The check for OSError (IOError, then) was from shortly after the module was first added, in February of 2001 by Ka-Ping Yee.

So, the motivation behind this behavior are shrouded in the mists of time :)

Should we really be changing something of that long standing, when it raising a TypeError previously clearly broke something?

I'm thinking not.  I'm thinking we should leave well enough alone.  It is, after all, working as documented....in the doc string, from the time Jeremy made the TypeError change.  So after all this work (sorry people, I do appreciate the work!), I think we should just make a doc fix that copies the line about returning None if source can't be found into the rst docs.
History
Date User Action Args
2013-10-09 20:04:10r.david.murraysetrecipients: + r.david.murray, ezio.melotti, docs@python, marco.buttu, pconnell, vajrasky
2013-10-09 20:04:10r.david.murraysetmessageid: <1381349050.11.0.252817019187.issue16355@psf.upfronthosting.co.za>
2013-10-09 20:04:10r.david.murraylinkissue16355 messages
2013-10-09 20:04:09r.david.murraycreate