[New-bugs-announce] [issue8782] inspect.getsource returns invalid source for non-newline-ending module
report at bugs.python.org
Fri May 21 16:34:09 CEST 2010
New submission from holger krekel <holger.krekel at gmail.com>:
Executing the attached "inspect_failure.py" under python2.6 or python3.1 results in an assertion error: Python fails to obtain the source code of a function that is defined at the end of a module whose last line does not contain a line ending character.
After brief analysis i think there are two approaches to fixing it: normalizing newlines in inspect.findsource (see attached inspect.patch file against r312) or performing normalization in linecache.updatecache which does it already for source code obtained from PEP302 loaders. Or any other ideas?
title: inspect.getsource returns invalid source for non-newline-ending module
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file17431/inspect.patch
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce