[issue9284] inspect.findsource() cannot find source for doctest code

Dirkjan Ochtman report at bugs.python.org
Sat Jul 17 16:24:47 CEST 2010

Dirkjan Ochtman <dirkjan at ochtman.nl> added the comment:

Here's a test case that doesn't require doctest trickery:

import inspect, linecache
fn, source = '<test>', 'def x(): pass\n'
getlines = linecache.getlines
def monkey(filename, module_globals=None):
     if filename == fn:
         return source.splitlines(True)
         return getlines(filename, module_globals)
linecache.getlines = monkey
exec compile(source, fn, 'single') in globals()


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list