New submission from holger krekel <holger.kre...@gmail.com>:

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()

----------
components: Library (Lib)
messages: 105776
nosy: benjamin.peterson, hpk
priority: normal
severity: normal
status: open
title: undo findsource regression/change
type: behavior
versions: Python 3.1

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8720>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to