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 hpk
Recipients benjamin.peterson, hpk
Date 2010-05-14.22:59:53
SpamBayes Score 2.2431052e-06
Marked as misclassified No
Message-id <1273877995.17.0.0354087541128.issue8720@psf.upfronthosting.co.za>
In-reply-to
Content
Somewhere between python 3.0.1 and 3.1.2 the behaviour of inspect.findsource changed: it does not find the source code anymore for a code object whose filename/source is in the linecache.cache because instead of the previous::

    file = getsourcefile(object) or getfile(object)

it only does now::

    file = getsourcefile(object) 

IMO it is enough if findsource() raises if it can't eventually discover the source code - i don't see the need to do this ahead.

In any case, the r312 findsource version requires an ugly work around within py.test in order for it to continue to be able to use the inspect module with dynamically compiled code.  The underlying issue is that at code-compile time no sensible (PEP302 compliantly loaded) module can be constructed because this is only known at exec-time but this is not part of the test tool API and is done somewhere in user code. 

Proposed fix: revert to r301 behaviour and add back "or getfile(object)" to the first line of inspect.findsource()
History
Date User Action Args
2010-05-14 22:59:55hpksetrecipients: + hpk, benjamin.peterson
2010-05-14 22:59:55hpksetmessageid: <1273877995.17.0.0354087541128.issue8720@psf.upfronthosting.co.za>
2010-05-14 22:59:53hpklinkissue8720 messages
2010-05-14 22:59:53hpkcreate